Skip to content

Commit d1e29d1

Browse files
authored
resource/aws_ses_template: Add arn attribute (#13963)
References: - https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonses.html#amazonses-resources-for-iam-policies - https://docs.aws.amazon.com/ses/latest/APIReference/API_Template.html (no arn or owner id fields) Output from acceptance testing: ``` --- PASS: TestAccAWSSesTemplate_disappears (10.40s) --- PASS: TestAccAWSSesTemplate_basic (12.74s) --- SKIP: TestAccAWSSesTemplate_Update (0.00s) ```
1 parent 928ca34 commit d1e29d1

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

.changelog/13963.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/aws_ses_template: Add `arn` attribute
3+
```

aws/resource_aws_ses_template.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66

77
"github.com/aws/aws-sdk-go/aws"
8+
"github.com/aws/aws-sdk-go/aws/arn"
89
"github.com/aws/aws-sdk-go/service/ses"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -22,6 +23,10 @@ func resourceAwsSesTemplate() *schema.Resource {
2223
},
2324

2425
Schema: map[string]*schema.Schema{
26+
"arn": {
27+
Type: schema.TypeString,
28+
Computed: true,
29+
},
2530
"name": {
2631
Type: schema.TypeString,
2732
Required: true,
@@ -102,6 +107,15 @@ func resourceAwsSesTemplateRead(d *schema.ResourceData, meta interface{}) error
102107
d.Set("subject", gto.Template.SubjectPart)
103108
d.Set("text", gto.Template.TextPart)
104109

110+
arn := arn.ARN{
111+
Partition: meta.(*AWSClient).partition,
112+
Service: "ses",
113+
Region: meta.(*AWSClient).region,
114+
AccountID: meta.(*AWSClient).accountid,
115+
Resource: fmt.Sprintf("template/%s", d.Id()),
116+
}.String()
117+
d.Set("arn", arn)
118+
105119
return nil
106120
}
107121

aws/resource_aws_ses_template_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/aws/aws-sdk-go/aws"
9-
"github.com/aws/aws-sdk-go/aws/awserr"
109
"github.com/aws/aws-sdk-go/service/ses"
1110
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1211
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -57,6 +56,7 @@ func TestAccAWSSesTemplate_Update(t *testing.T) {
5756
Config: testAccCheckAwsSesTemplateResourceConfigBasic1(rName),
5857
Check: resource.ComposeTestCheckFunc(
5958
testAccCheckSesTemplateExists(resourceName, &template),
59+
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "ses", fmt.Sprintf("template/%s", rName)),
6060
resource.TestCheckResourceAttr(resourceName, "name", rName),
6161
resource.TestCheckResourceAttr(resourceName, "html", "html"),
6262
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
@@ -159,7 +159,7 @@ func testAccCheckSesTemplateDestroy(s *terraform.State) error {
159159

160160
gto, err := conn.GetTemplate(&input)
161161
if err != nil {
162-
if awsErr, ok := err.(awserr.Error); ok && (awsErr.Code() == "TemplateDoesNotExist") {
162+
if isAWSErr(err, ses.ErrCodeTemplateDoesNotExistException, "") {
163163
return nil
164164
}
165165
return resource.NonRetryableError(err)

website/docs/index.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ for more information about connecting to alternate AWS endpoints or AWS compatib
320320
- [`aws_ses_email_identity` resource](/docs/providers/aws/r/ses_email_identity.html)
321321
- [`aws_ses_event_destination` resource](/docs/providers/aws/r/ses_event_destination.html)
322322
- [`aws_ses_receipt_filter` resource](/docs/providers/aws/r/ses_receipt_filter.html)
323+
- [`aws_ses_template` resource](/docs/providers/aws/r/ses_template.html)
323324
- [`aws_ssm_document` data source](/docs/providers/aws/d/ssm_document.html)
324325
- [`aws_ssm_document` resource](/docs/providers/aws/r/ssm_document.html)
325326
- [`aws_ssm_parameter` data source](/docs/providers/aws/d/ssm_parameter.html)

website/docs/r/ses_template.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following arguments are supported:
3434

3535
In addition to all arguments above, the following attributes are exported:
3636

37+
* `arn` - The ARN of the SES template
3738
* `id` - The name of the SES template
3839

3940
## Import

0 commit comments

Comments
 (0)