-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 import for aws_iam_role_policy_attachment #5910
Add import for aws_iam_role_policy_attachment #5910
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.
LGTM, thanks @jzbruno! 🚀 Please note I made the minor adjustment in a followup commit and added some comments about the lack of ImportStateVerify
.
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSRolePolicyAttachment_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSRolePolicyAttachment_basic -timeout 120m
=== RUN TestAccAWSRolePolicyAttachment_basic
--- PASS: TestAccAWSRolePolicyAttachment_basic (16.19s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 16.920s
@@ -93,6 +98,21 @@ func testAccCheckAWSRolePolicyAttachmentAttributes(policies []string, out *iam.L | |||
} | |||
} | |||
|
|||
func testAccAWSIAMRolePolicyAttachmentImportStateIdFunc(s *terraform.State) (string, error) { |
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.
Minor nitpick: For future maintainability, we should parameterize this and only depend on the resource in question (aws_iam_role_policy_attachment
). e.g.
func testAccAWSIAMRolePolicyAttachmentImportStateIdFunc(resourceName string) resource.ImportStateIdFunc {
return func(s *terraform.State) (string, error) {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return "", fmt.Errorf("Not found: %s", resourceName)
}
return fmt.Sprintf("%s/%s", rs.Primary.Attributes["role"], rs.Primary.Attributes["policy_arn"]), nil
}
}
This has been released in version 1.37.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! |
Fixes #544
Changes proposed in this pull request:
Output from acceptance testing: