Skip to content
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

Merged
merged 1 commit into from
Aug 7, 2017

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Aug 2, 2017

Closes #693

The first error code (InvalidCloudWatchLogsRoleArnException) comes from the bug report, second one (InvalidCloudWatchLogsLogGroupArnException) comes from testing of #1357.

@radeksimko radeksimko added the bug Addresses a defect in current functionality. label Aug 2, 2017
@radeksimko radeksimko force-pushed the b-cloudtrail-retry branch 4 times, most recently from b5201eb to f189508 Compare August 5, 2017 20:57
Copy link
Contributor

@Ninir Ninir left a 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

if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") {
return resource.RetryableError(err)
}
if isAWSErr(err, "InvalidCloudWatchLogsLogGroupArnException", "Access denied.") {
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member Author

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).

Copy link
Member Author

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.

var err error
t, err = conn.CreateTrail(&input)
if err != nil {
if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") {
Copy link
Contributor

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?

Copy link
Member Author

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! :trollface: but trolling aside - yes, constant makes sense in this context and it may help avoiding typos. I'll change it.

if isAWSErr(err, "InvalidCloudWatchLogsRoleArnException", "Access denied.") {
return resource.RetryableError(err)
}
if isAWSErr(err, "InvalidCloudWatchLogsLogGroupArnException", "Access denied.") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for constants :)

@radeksimko
Copy link
Member Author

radeksimko commented Aug 7, 2017

@Ninir addressed your comments regarding constants. 😉

@Ninir
Copy link
Contributor

Ninir commented Aug 7, 2017

👍

@radeksimko radeksimko merged commit 613a474 into master Aug 7, 2017
@radeksimko radeksimko deleted the b-cloudtrail-retry branch August 7, 2017 09:46
@ghost
Copy link

ghost commented Apr 11, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudTrail resource creation failure when creating aws_iam_role and aws_iam_role_policy in single run
2 participants