-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add support for resource_aws_ses_identity_notification_topic import #7343
Add support for resource_aws_ses_identity_notification_topic import #7343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jkmart 👋 Thanks for submitting this. Please see the below feedback and let us know if you have any questions or do not have time to implement these items.
@@ -17,6 +17,9 @@ func resourceAwsSesNotificationTopic() *schema.Resource { | |||
Read: resourceAwsSesNotificationTopicRead, | |||
Update: resourceAwsSesNotificationTopicSet, | |||
Delete: resourceAwsSesNotificationTopicDelete, | |||
Importer: &schema.ResourceImporter{ | |||
State: resourceAwsSesNotificationImport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since resourceAwsSesNotificationTopicRead
already handles parsing the "complex" IDENTITY|TYPE
, we can skip the custom import function and instead appropriately fill in the missing d.Set()
in resourceAwsSesNotificationTopicRead
, e.g.
State: resourceAwsSesNotificationImport, | |
State: schema.ImportStatePassthrough, |
// remove resourceAwsSesNotificationImport
// add to resourceAwsSesNotificationTopicRead
d.Set("identity", identity)
d.Set("notification_type", notificationType)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, made the change.
@@ -41,6 +41,30 @@ func TestAccAwsSESIdentityNotificationTopic_basic(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestAccAwsSESIdentityNotification_importBasic(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating bespoke _import
acceptance tests, which requires duplication of testing infrastructure, we prefer to instead add the TestStep
with ImportState: true
and ImportStateVerify: true
to all existing acceptance tests. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay got it, didn't see a good example of that in my brief skim through other tests. Changed.
To import the ID above, it would look as follows: | ||
|
||
``` | ||
$ import aws_ses_identity_notification_topic.test example.com|Bounce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing terraform
and should likely wrap the pipe in single quotes to prevent shell issues
$ import aws_ses_identity_notification_topic.test example.com|Bounce | |
$ terraform import aws_ses_identity_notification_topic.test 'example.com|Bounce' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
Made the changes.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks so much @jkmart! 🚀
--- PASS: TestAccAwsSESIdentityNotificationTopic_basic (18.57s)
This has been released in version 1.59.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Changes proposed in this pull request:
Output from acceptance testing: