Secrets manager policy validation fails for principals that are just created #14449
Labels
bug
Addresses a defect in current functionality.
service/iam
Issues and PRs that pertain to the iam service.
service/secretsmanager
Issues and PRs that pertain to the secretsmanager service.
Milestone
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.12.16
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Secret is generated with the appropriate permission at the first apply
Actual Behavior
The validation for the policy fails with the following output
data.aws_caller_identity.current: Refreshing state...
aws_iam_role.this: Creating...
aws_iam_role.this: Creation complete after 2s [id=instance-profile-test]
data.aws_iam_policy_document.this: Refreshing state...
aws_secretsmanager_secret.this: Creating...
Error: error setting Secrets Manager Secret "arn:aws:secretsmanager:ap-southeast-2:XXXXXXX: secret:test-e5XYyU" policy: MalformedPolicyDocumentException: This resource policy contains an unsupported principal.
on main.tf line 6, in resource "aws_secretsmanager_secret" "this":
6: resource "aws_secretsmanager_secret" "this" {
NOTE: a subsequent apply works as expected. I suspect the validation of the policy happens before the IAM role arn is actually available for querying due to IAM eventual consistency
Steps to Reproduce
terraform destroy
terraform apply
--> Generate an errorterraform apply
--> Successful executionThe text was updated successfully, but these errors were encountered: