From 9746d0fdb58d6fece1f6a750168bb0c148485428 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 26 Jun 2020 23:20:12 +0300 Subject: [PATCH 1/7] add arn --- ...esource_aws_ses_active_receipt_rule_set.go | 21 ++++++++++++++++--- ...ce_aws_ses_active_receipt_rule_set_test.go | 5 +++-- .../docs/r/ses_receipt_rule_set.html.markdown | 8 +++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_ses_active_receipt_rule_set.go b/aws/resource_aws_ses_active_receipt_rule_set.go index e44b526469a..bfd58704353 100644 --- a/aws/resource_aws_ses_active_receipt_rule_set.go +++ b/aws/resource_aws_ses_active_receipt_rule_set.go @@ -5,6 +5,7 @@ import ( "log" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/ses" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) @@ -17,6 +18,10 @@ func resourceAwsSesActiveReceiptRuleSet() *schema.Resource { Delete: resourceAwsSesActiveReceiptRuleSetDelete, Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, "rule_set_name": { Type: schema.TypeString, Required: true, @@ -59,13 +64,23 @@ func resourceAwsSesActiveReceiptRuleSetRead(d *schema.ResourceData, meta interfa return err } - if response.Metadata != nil { - d.Set("rule_set_name", response.Metadata.Name) - } else { + if response.Metadata == nil { log.Print("[WARN] No active Receipt Rule Set found") d.SetId("") + return nil } + d.Set("rule_set_name", response.Metadata.Name) + + arn := arn.ARN{ + Partition: meta.(*AWSClient).partition, + Service: "ses", + Region: meta.(*AWSClient).region, + AccountID: meta.(*AWSClient).accountid, + Resource: fmt.Sprintf("receipt-rule-set/%s", d.Id()), + }.String() + d.Set("arn", arn) + return nil } diff --git a/aws/resource_aws_ses_active_receipt_rule_set_test.go b/aws/resource_aws_ses_active_receipt_rule_set_test.go index 370478dd89a..35a715d0a8a 100644 --- a/aws/resource_aws_ses_active_receipt_rule_set_test.go +++ b/aws/resource_aws_ses_active_receipt_rule_set_test.go @@ -27,6 +27,7 @@ func TestAccAWSSESActiveReceiptRuleSet_basic(t *testing.T) { Config: testAccAWSSESActiveReceiptRuleSetConfig(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAwsSESActiveReceiptRuleSetExists(resourceName), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "ses", fmt.Sprintf("receipt-rule-set/%s", rName)), ), }, }, @@ -109,11 +110,11 @@ func testAccCheckAwsSESActiveReceiptRuleSetExists(n string) resource.TestCheckFu func testAccAWSSESActiveReceiptRuleSetConfig(name string) string { return fmt.Sprintf(` resource "aws_ses_receipt_rule_set" "test" { - rule_set_name = "%s" + rule_set_name = %[1]q } resource "aws_ses_active_receipt_rule_set" "test" { - rule_set_name = "${aws_ses_receipt_rule_set.test.rule_set_name}" + rule_set_name = "${aws_ses_receipt_rule_set.test.rule_set_name}" } `, name) } diff --git a/website/docs/r/ses_receipt_rule_set.html.markdown b/website/docs/r/ses_receipt_rule_set.html.markdown index 7cfe382a753..f7d135a7e9c 100644 --- a/website/docs/r/ses_receipt_rule_set.html.markdown +++ b/website/docs/r/ses_receipt_rule_set.html.markdown @@ -24,6 +24,14 @@ The following arguments are supported: * `rule_set_name` - (Required) The name of the rule set +## Attributes Reference + +In addition to the arguments, which are exported, the following attributes are exported: + +* `id` - The SES receipt rule set name. +* `arn` - The SES receipt rule set ARN. + + ## Import SES receipt rule sets can be imported using the rule set name. From 75b299a044cea641cdf7a3f4aef082a818611850 Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Sat, 27 Jun 2020 22:33:22 +0300 Subject: [PATCH 2/7] Update ses_receipt_rule_set.html.markdown --- website/docs/r/ses_receipt_rule_set.html.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/r/ses_receipt_rule_set.html.markdown b/website/docs/r/ses_receipt_rule_set.html.markdown index f7d135a7e9c..dee176212b2 100644 --- a/website/docs/r/ses_receipt_rule_set.html.markdown +++ b/website/docs/r/ses_receipt_rule_set.html.markdown @@ -31,7 +31,6 @@ In addition to the arguments, which are exported, the following attributes are e * `id` - The SES receipt rule set name. * `arn` - The SES receipt rule set ARN. - ## Import SES receipt rule sets can be imported using the rule set name. From 5a3bdb49bc1825584536523904aa51962cae96ab Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 25 Jul 2020 15:50:36 +0300 Subject: [PATCH 3/7] add docs --- website/docs/index.html.markdown | 1 + website/docs/r/ses_active_receipt_rule_set.html.markdown | 7 +++++++ website/docs/r/ses_receipt_rule_set.html.markdown | 7 ------- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index 61856f987f8..509c9fcaa9b 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -280,6 +280,7 @@ for more information about connecting to alternate AWS endpoints or AWS compatib - [`aws_ses_domain_identity_verification` resource](/docs/providers/aws/r/ses_domain_identity_verification.html) - [`aws_ses_email_identity` resource](/docs/providers/aws/r/ses_email_identity.html) - [`aws_ses_receipt_filter` resource](/docs/providers/aws/r/ses_receipt_filter.html) + - [`aws_ses_active_receipt_rule_set` resource](/docs/providers/aws/r/ses_active_receipt_rule_set.html) - [`aws_ssm_document` data source](/docs/providers/aws/d/ssm_document.html) - [`aws_ssm_document` resource](/docs/providers/aws/r/ssm_document.html) - [`aws_ssm_parameter` data source](/docs/providers/aws/d/ssm_parameter.html) diff --git a/website/docs/r/ses_active_receipt_rule_set.html.markdown b/website/docs/r/ses_active_receipt_rule_set.html.markdown index 25db2e57033..23fb50b536c 100644 --- a/website/docs/r/ses_active_receipt_rule_set.html.markdown +++ b/website/docs/r/ses_active_receipt_rule_set.html.markdown @@ -23,3 +23,10 @@ resource "aws_ses_active_receipt_rule_set" "main" { The following arguments are supported: * `rule_set_name` - (Required) The name of the rule set + +## Attributes Reference + +In addition to the arguments, which are exported, the following attributes are exported: + +* `id` - The SES receipt rule set name. +* `arn` - The SES receipt rule set ARN. diff --git a/website/docs/r/ses_receipt_rule_set.html.markdown b/website/docs/r/ses_receipt_rule_set.html.markdown index dee176212b2..7cfe382a753 100644 --- a/website/docs/r/ses_receipt_rule_set.html.markdown +++ b/website/docs/r/ses_receipt_rule_set.html.markdown @@ -24,13 +24,6 @@ The following arguments are supported: * `rule_set_name` - (Required) The name of the rule set -## Attributes Reference - -In addition to the arguments, which are exported, the following attributes are exported: - -* `id` - The SES receipt rule set name. -* `arn` - The SES receipt rule set ARN. - ## Import SES receipt rule sets can be imported using the rule set name. From fa34c7f075d8828b490109989d6783ce2796fe3f Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Thu, 12 Nov 2020 20:44:18 +0200 Subject: [PATCH 4/7] arn doc --- website/docs/index.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index 09a9f94658a..aa63ce722b5 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -318,7 +318,7 @@ for more information about connecting to alternate AWS endpoints or AWS compatib - [`aws_ses_domain_identity_verification` resource](/docs/providers/aws/r/ses_domain_identity_verification.html) - [`aws_ses_email_identity` resource](/docs/providers/aws/r/ses_email_identity.html) - [`aws_ses_receipt_filter` resource](/docs/providers/aws/r/ses_receipt_filter.html) - - [`aws_ses_active_receipt_rule_set` resource](/docs/providers/aws/r/ses_active_receipt_rule_set.html) + - [`aws_ses_active_receipt_rule_set` resource](/docs/providers/aws/r/ses_active_receipt_rule_set.html) - [`aws_ssm_document` data source](/docs/providers/aws/d/ssm_document.html) - [`aws_ssm_document` resource](/docs/providers/aws/r/ssm_document.html) - [`aws_ssm_parameter` data source](/docs/providers/aws/d/ssm_parameter.html) From 149ddf4640457d4120dd1b13163e865ded92cfd0 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Thu, 11 Feb 2021 17:43:23 +0200 Subject: [PATCH 5/7] add validation + changelog --- .changelog/13962.txt | 8 ++++++++ aws/resource_aws_ses_active_receipt_rule_set.go | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changelog/13962.txt diff --git a/.changelog/13962.txt b/.changelog/13962.txt new file mode 100644 index 00000000000..9db4893cc53 --- /dev/null +++ b/.changelog/13962.txt @@ -0,0 +1,8 @@ +```release-note:enhancement +resource/ses_active_receipt_rule_set: Add `arn` attribute. +``` + +```release-note:enhancement +resource/ses_active_receipt_rule_set: Add plan time validation for `name`. +``` + diff --git a/aws/resource_aws_ses_active_receipt_rule_set.go b/aws/resource_aws_ses_active_receipt_rule_set.go index 80e07318b43..b506278ee56 100644 --- a/aws/resource_aws_ses_active_receipt_rule_set.go +++ b/aws/resource_aws_ses_active_receipt_rule_set.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/ses" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func resourceAwsSesActiveReceiptRuleSet() *schema.Resource { @@ -23,8 +24,9 @@ func resourceAwsSesActiveReceiptRuleSet() *schema.Resource { Computed: true, }, "rule_set_name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 64), }, }, } From 13b9c63089af28455ad3c5cf7d66f3803136fbdf Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Thu, 11 Feb 2021 17:44:07 +0200 Subject: [PATCH 6/7] fix changelog --- .changelog/13962.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/13962.txt b/.changelog/13962.txt index 9db4893cc53..0c0ac31348a 100644 --- a/.changelog/13962.txt +++ b/.changelog/13962.txt @@ -3,6 +3,6 @@ resource/ses_active_receipt_rule_set: Add `arn` attribute. ``` ```release-note:enhancement -resource/ses_active_receipt_rule_set: Add plan time validation for `name`. +resource/ses_active_receipt_rule_set: Add plan time validation for `rule_set_name`. ``` From 7d6aba4bcaf3d075302813e37dc93089beef4094 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 11 Feb 2021 12:39:03 -0500 Subject: [PATCH 7/7] Apply suggestions from code review --- .changelog/13962.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.changelog/13962.txt b/.changelog/13962.txt index 0c0ac31348a..ce98a3fd700 100644 --- a/.changelog/13962.txt +++ b/.changelog/13962.txt @@ -1,8 +1,7 @@ ```release-note:enhancement -resource/ses_active_receipt_rule_set: Add `arn` attribute. +resource/aws_ses_active_receipt_rule_set: Add `arn` attribute ``` ```release-note:enhancement -resource/ses_active_receipt_rule_set: Add plan time validation for `rule_set_name`. +resource/aws_ses_active_receipt_rule_set: Add plan time validation for `rule_set_name` argument ``` -