-
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
fix: Invalid repo policy due to IAM eventual consistency #1165
fix: Invalid repo policy due to IAM eventual consistency #1165
Conversation
@radeksimko I've based this PR on hashicorp/terraform@fad019e Any test I should write for this? If yes, please help me to start. |
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 overall sensible thing to do. Even though I wasn't able to reproduce it I believe you this may happen.
Just one thing I'd change in this PR is how we catch the error. Matching just code InvalidParameterException
seems too broad to me.
How about something like this?
if isAWSErr(err, "InvalidParameterException", "Invalid repository policy provided") {
Also with this approach ^ you can leave out the if !ok {
condition and let it fall through to the return
at the bottom.
I'm surprised you did not manage to reproduce it based on #1164. After your comment I thought: maybe your region handles propagation faster. I'm just about to make the requested changes. Good points. Before retry in place:
After retry in place:
|
I've added a new log - retry in place - to the Gist provided with the original issue. The retry is clearly happening...
|
If I try to use a newly created IAM role's ARN in an ECR policy's principal field, I got: 'Invalid repository policy provided'. IAM changes need time to propagate to other services like S3, ECR. There is no upper bound granted by AWS on propagation time, but usually 1 minute should be enough. https://forums.aws.amazon.com/thread.jspa?messageID=195539#195539 A similar retry logic is already present in aws/resource_aws_ecs_service.go Compared to the ECS Service resource; isAWSErr() makes the retry logic simpler and the dropped DEBUG statements did not add an extra info. (Request-ID, error message, retry info is all visible in the log without the extra Printf() call.) Note: I did not find any way to fix this on the 'aws_iam_role' resource side, since the IAM API reflects the changes immediately and does not provide any info about the propagation status. fixes #1164 Signed-off-by: Ferenc Szabo <frncmx@gmail.com>
Changed as requested. As requested in the contributing guideline, I've also tried to write my 1st acceptance test for Terraform. I'm really not sure about the |
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.
🍾 Thanks. :) |
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! |
If I try to use a newly created IAM role's ARN in an ECR policy's
principal field, I got: 'Invalid repository policy provided'.
IAM changes need time to propagate to other services like S3, ECR.
There is no upper bound granted by AWS on propagation time, but
usually 1 minute should be enough.
https://forums.aws.amazon.com/thread.jspa?messageID=195539#195539
A similar retry logic is already present in aws/resource_aws_ecs_service.go
Compared to the ECS Service resource; isAWSErr() makes the retry logic simpler
and the dropped DEBUG statements did not add an extra info.
(Request-ID, error message, retry info is all visible in the log without the
extra Printf() call.)
Note: I did not find any way to fix this on the 'aws_iam_role'
resource side, since the IAM API reflects the changes immediately and
does not provide any info about the propagation status.
fixes #1164
Signed-off-by: Ferenc Szabo frncmx@gmail.com