Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/ses_active_receipt_rule_set - add arn attribute #13962

Merged
merged 9 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/13962.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_ses_active_receipt_rule_set: Add `arn` attribute
```

```release-note:enhancement
resource/aws_ses_active_receipt_rule_set: Add plan time validation for `rule_set_name` argument
```
27 changes: 22 additions & 5 deletions aws/resource_aws_ses_active_receipt_rule_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ 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/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func resourceAwsSesActiveReceiptRuleSet() *schema.Resource {
Expand All @@ -17,9 +19,14 @@ func resourceAwsSesActiveReceiptRuleSet() *schema.Resource {
Delete: resourceAwsSesActiveReceiptRuleSetDelete,

Schema: map[string]*schema.Schema{
"rule_set_name": {
"arn": {
Type: schema.TypeString,
Required: true,
Computed: true,
},
"rule_set_name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringLenBetween(1, 64),
},
},
}
Expand Down Expand Up @@ -59,13 +66,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
}

Expand Down
3 changes: 2 additions & 1 deletion aws/resource_aws_ses_active_receipt_rule_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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)),
),
},
},
Expand Down Expand Up @@ -128,7 +129,7 @@ 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" {
Expand Down
5 changes: 3 additions & 2 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,13 @@ for more information about connecting to alternate AWS endpoints or AWS compatib
- [`aws_redshift_snapshot_schedule` resource](/docs/providers/aws/r/redshift_snapshot_schedule.html)
- [`aws_redshift_subnet_group` resource](/docs/providers/aws/r/redshift_subnet_group.html)
- [`aws_s3_account_public_access_block` resource](/docs/providers/aws/r/s3_account_public_access_block.html)
- [`aws_ses_active_receipt_rule_set` resource](/docs/providers/aws/r/ses_active_receipt_rule_set.html)
- [`aws_ses_domain_identity` resource](/docs/providers/aws/r/ses_domain_identity.html)
- [`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_event_destination` resource](/docs/providers/aws/r/ses_event_destination.html)
- [`aws_ses_event_destination` resource](/docs/providers/aws/r/ses_event_destination.html)
- [`aws_ses_receipt_filter` resource](/docs/providers/aws/r/ses_receipt_filter.html)
- [`aws_ses_template` resource](/docs/providers/aws/r/ses_template.html)
- [`aws_ses_template` resource](/docs/providers/aws/r/ses_template.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)
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/ses_active_receipt_rule_set.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.