Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

platform/api/aws: add additional checks in ensureInstanceProfile #1058

Closed
wants to merge 1 commit into from

Conversation

arithx
Copy link
Contributor

@arithx arithx commented Sep 16, 2019

Adds some additional checks in the ensureInstanceProfile function that
not only does the instance profile exist but it has the correct role
(with the correct policies) attached to it.

Closes #1047

Adds some additional checks in the `ensureInstanceProfile` function that
not only does the instance profile exist but it has the correct role
(with the correct policies) attached to it.
@dustymabe
Copy link
Member

LGTM but I'm no golang programmer :)

return fmt.Errorf("getting instance profile %q: %v", name, err)
} else if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just fold back this whole block with the rest of the logic below and just be more idempotent? E.g.:

- CreateInstanceProfile, ignore EntityAlreadyExists
- CreateRole, ignore EntityAlreadyExists
- PutRolePolicy (seems like that API is already idempotent)
- AddRoleToInstanceProfile, ignore EntityAlreadyExists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do like the approach, the main deviation from what you have listed is AddRoleToInstanceProfile, in testing this is actually not returning an EntityAlreadyExists but rather a LimitExceeded because the default limit for InstanceSessionsPerInstanceProfile is 1 (essentially each instance profile can only have one role).

I'm not sure I feel that error is sufficient towards ensuring that the correct Role is attached to the InstanceProfile. Perhaps I'll just add a check there in addition to ignoring the EntityAlreadyExists errors on CreateInstanceProfile & CreateRole

@arithx
Copy link
Contributor Author

arithx commented Dec 2, 2019

Closing as this is extremely old

@arithx arithx closed this Dec 2, 2019
@dustymabe
Copy link
Member

no longer useful?

@arithx
Copy link
Contributor Author

arithx commented Dec 2, 2019

@dustymabe not necessarily, the bug is still there but it's an extreme corner case that users aren't likely to hit. I still have the branch on my fork if we decide to go back in the future to fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws: kola iam role can get into weird state if user doesn't have passrole perms
3 participants