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_template - add arn attribute #13963

Merged
merged 4 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
3 changes: 3 additions & 0 deletions .changelog/13963.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ses_template: Add `arn` attribute
```
14 changes: 14 additions & 0 deletions aws/resource_aws_ses_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand All @@ -22,6 +23,10 @@ func resourceAwsSesTemplate() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -102,6 +107,15 @@ func resourceAwsSesTemplateRead(d *schema.ResourceData, meta interface{}) error
d.Set("subject", gto.Template.SubjectPart)
d.Set("text", gto.Template.TextPart)

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "ses",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: fmt.Sprintf("template/%s", d.Id()),
}.String()
d.Set("arn", arn)

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_ses_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -57,6 +56,7 @@ func TestAccAWSSesTemplate_Update(t *testing.T) {
Config: testAccCheckAwsSesTemplateResourceConfigBasic1(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckSesTemplateExists(resourceName, &template),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "ses", fmt.Sprintf("template/%s", rName)),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "html", "html"),
resource.TestCheckResourceAttr(resourceName, "subject", "subject"),
Expand Down Expand Up @@ -159,7 +159,7 @@ func testAccCheckSesTemplateDestroy(s *terraform.State) error {

gto, err := conn.GetTemplate(&input)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok && (awsErr.Code() == "TemplateDoesNotExist") {
if isAWSErr(err, ses.ErrCodeTemplateDoesNotExistException, "") {
return nil
}
return resource.NonRetryableError(err)
Expand Down
1 change: 1 addition & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,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_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
1 change: 1 addition & 0 deletions website/docs/r/ses_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following arguments are supported:

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

* `arn` - The ARN of the SES template
* `id` - The name of the SES template

## Import
Expand Down