-
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 account ID to the SSM document ARN #4436
Add account ID to the SSM document ARN #4436
Conversation
Without the account ID being specified if the ARN output is used as an allowed resource in an IAM policy then the IAM policy doesn't match the document and you get a permissions error from IAM when executing the document.
d784383
to
02d074b
Compare
Config: testAccAWSSSMDocumentBasicConfig(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSSSMDocumentExists("aws_ssm_document.foo"), | ||
resource.TestCheckResourceAttr("aws_ssm_document.foo", "document_format", "JSON"), | ||
resource.TestMatchResourceAttr("aws_ssm_document.foo", "arn", | ||
regexp.MustCompile(`^arn:aws:ssm:[a-z]{2}-[a-z]+-\d{1}:\d{12}:document/.*$`)), |
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.
Thanks for this very accurate test check for the Commercial partition -- we'll be making these more generic so we can also support testing in GovCloud (US) and China at some point in the near future:
regexp.MustCompile(`^arn:[^:]+:ssm:[^:]+:\d{12}:document/.*$`))
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.
Ha, I originally had the regex match gov-cloud as well and figured it was a waste of time because we didn't run the tests in gov-cloud/china and so took it out to simplify the regex. Didn't think about matching all non colon characters for the region and partition though.
I'll keep that in mind for anything else I add in future.
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.
Thanks @tomelliff! 🚀
Commercial
6 tests passed (all tests)
=== RUN TestAccAWSSSMDocument_params
--- PASS: TestAccAWSSSMDocument_params (8.94s)
=== RUN TestAccAWSSSMDocument_permission
--- PASS: TestAccAWSSSMDocument_permission (12.54s)
=== RUN TestAccAWSSSMDocument_update
--- PASS: TestAccAWSSSMDocument_update (15.31s)
=== RUN TestAccAWSSSMDocument_basic
--- PASS: TestAccAWSSSMDocument_basic (15.48s)
=== RUN TestAccAWSSSMDocument_DocumentFormat_YAML
--- PASS: TestAccAWSSSMDocument_DocumentFormat_YAML (21.07s)
=== RUN TestAccAWSSSMDocument_automation
--- PASS: TestAccAWSSSMDocument_automation (33.68s)
@bflad thanks for the review and merge again :) |
This has been released in version 1.18.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! |
Without the account ID being specified if the ARN output is used as an allowed resource in an IAM policy then the IAM policy doesn't match the document and you get a permissions error from IAM when executing the document.