Skip to content

Commit

Permalink
Merge pull request #7343 from jkmart/resource-aws-ses-identity-notifi…
Browse files Browse the repository at this point in the history
…cation-topic-importer

Add support for resource_aws_ses_identity_notification_topic import
  • Loading branch information
bflad authored Feb 12, 2019
2 parents 78cb974 + f2e21cf commit a3de834
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions aws/resource_aws_ses_identity_notification_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func resourceAwsSesNotificationTopic() *schema.Resource {
Read: resourceAwsSesNotificationTopicRead,
Update: resourceAwsSesNotificationTopicSet,
Delete: resourceAwsSesNotificationTopicDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"topic_arn": {
Expand Down Expand Up @@ -79,6 +82,9 @@ func resourceAwsSesNotificationTopicRead(d *schema.ResourceData, meta interface{
return err
}

d.Set("identity", identity)
d.Set("notification_type", notificationType)

getOpts := &ses.GetIdentityNotificationAttributesInput{
Identities: []*string{aws.String(identity)},
}
Expand Down
10 changes: 8 additions & 2 deletions aws/resource_aws_ses_identity_notification_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestAccAwsSESIdentityNotificationTopic_basic(t *testing.T) {
"%s.terraformtesting.com",
acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
topicName := fmt.Sprintf("test-topic-%d", acctest.RandInt())
resourceName := "aws_ses_identity_notification_topic.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -28,15 +29,20 @@ func TestAccAwsSESIdentityNotificationTopic_basic(t *testing.T) {
{
Config: fmt.Sprintf(testAccAwsSESIdentityNotificationTopicConfig_basic, domain),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsSESIdentityNotificationTopicExists("aws_ses_identity_notification_topic.test"),
testAccCheckAwsSESIdentityNotificationTopicExists(resourceName),
),
},
{
Config: fmt.Sprintf(testAccAwsSESIdentityNotificationTopicConfig_update, domain, topicName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsSESIdentityNotificationTopicExists("aws_ses_identity_notification_topic.test"),
testAccCheckAwsSESIdentityNotificationTopicExists(resourceName),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
18 changes: 18 additions & 0 deletions website/docs/r/ses_identity_notification_topic.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ The following arguments are supported:
* `topic_arn` - (Optional) The Amazon Resource Name (ARN) of the Amazon SNS topic. Can be set to "" (an empty string) to disable publishing.
* `notification_type` - (Required) The type of notifications that will be published to the specified Amazon SNS topic. Valid Values: *Bounce*, *Complaint* or *Delivery*.
* `identity` - (Required) The identity for which the Amazon SNS topic will be set. You can specify an identity by using its name or by using its Amazon Resource Name (ARN).

## Import

Identity Notification Topics can be imported using ID of the record. The ID is made up as IDENTITY|TYPE where IDENTITY is the SES Identity and TYPE is the Notification Type.

e.g.

```
example.com|Bounce
```

In this example, `example.com` is the SES Identity and `Bounce` is the Notification Type.

To import the ID above, it would look as follows:

```
$ terraform import aws_ses_identity_notification_topic.test 'example.com|Bounce'
```

0 comments on commit a3de834

Please sign in to comment.