Open blakepettersson opened 2 years ago
To add some more context from my experiences with this issue --
The issue is specifically the sequence of ecr:CreateRepository
followed by ecr:SetRepositoryPolicy
(or ecr:PutLifecyclePolicy
) within the same apply
run. Subsequent runs of apply
work; they pick up with a repository that was created in the first run, and the policy(s) are applied without issue.
This does not appear to be a timing issue as I cannot repro the issue using the AWS CLI, but something about the difference between a repository create and a read repository from state.
Capturing debug traces, the outputs between a failure and a success are nearly identical; i.e. the request payloads look the same, just one 403s while one 200s.
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v1.2.8 on linux_amd64
Affected Resource(s)
aws_ecr_repository_policy
aws_iam_role_policy
Terraform Configuration Files
Debug Output
https://gist.github.com/blakepettersson/58e77cf4e3018cb34e544d9f65f7e67a
Expected Behavior
This should work consistently on the first
terraform apply
.Actual Behavior
This usually takes another
terraform apply
for this to work.Steps to Reproduce
terraform apply