-
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
r/cloudtrail: Retry if IAM role isn't propagated yet #1312
Conversation
b5201eb
to
f189508
Compare
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, just left 2 questions & self-appreciations of constant usages :D
aws/resource_aws_cloudtrail.go
Outdated
if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") { | ||
return resource.RetryableError(err) | ||
} | ||
if isAWSErr(err, "InvalidCloudWatchLogsLogGroupArnException", "Access denied.") { |
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.
What do you think of having a single if, checking for both conditions?
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.
Also, would also use ErrCodeInvalidCloudWatchLogsLogGroupArnException
here.
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.
I think the two if-s look tiny little bit cleaner (easier to read) compared to 1 if with 2 conditionals which would need to be line-wrapped (b/c long lines aren't easy to read either).
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.
Agreed about constant though. I'll change that.
aws/resource_aws_cloudtrail.go
Outdated
var err error | ||
t, err = conn.CreateTrail(&input) | ||
if err != nil { | ||
if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") { |
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.
I would use the cloudtail.ErrCodeInvalidCloudWatchLogsRoleArnException
constant, just for sanity and typo-less issues. Thoughts?
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.
It's 17 extra characters! but trolling aside - yes, constant makes sense in this context and it may help avoiding typos. I'll change it.
aws/resource_aws_cloudtrail.go
Outdated
if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") { | ||
return resource.RetryableError(err) | ||
} | ||
if isAWSErr(err, "InvalidCloudWatchLogsLogGroupArnException", "Access denied.") { |
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.
Same here for constants :)
f189508
to
0d7e9d8
Compare
@Ninir addressed your comments regarding constants. 😉 |
👍 |
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! |
Closes #693
The first error code (
InvalidCloudWatchLogsRoleArnException
) comes from the bug report, second one (InvalidCloudWatchLogsLogGroupArnException
) comes from testing of #1357.