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

Add support for pulling account assignment creation status #30

Merged
merged 5 commits into from
Jan 10, 2024

Conversation

jirwin
Copy link
Contributor

@jirwin jirwin commented Jan 9, 2024

When creating an account assignment(e.g. granting an sso account access to a permission set), it is actually an asynchronous process. This means that it isn't applied immediately, and the successful response from the create API request doesn't mean that provisioning was successful.

In order to validate the provisioning was successful, we must describe the status of the request, and wait for it to return successfully. It is possible for the request to fail for some reason after the fact, so we need to look out for that response, and return an error appropriately.

Unfortunately, this API requires an additional IAM permission that we don't request, so users will need to be update permissions for us to take advantage of this.

We should take a look and see if there are other async operations that we're doing, and generalize the wait loop if possible.

@jirwin jirwin marked this pull request as ready for review January 10, 2024 08:08
@jirwin jirwin requested review from loganintech and pquerna January 10, 2024 08:10
if err != nil {
var ae *awsSsoAdminTypes.AccessDeniedException
if errors.As(err, &ae) {
l.Info("aws-connector: access denied while attempting to check status. Assuming account assignment creation is complete.", zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should assume it worked here. But we also don't want to have had it worked and we report that it didn't. Hmm. Maybe this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to preserve the existing behavior and not break existing installs. Thoughts on another way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, also though imagine you make a request and we report it fails but in reality the person is actually provisioned. I think it's safer to assume it worked and be wrong than assume it didn't work and be wrong.


attemptCount++
attemptLogger.Debug("aws-connector: waiting for account assignment creation to complete, checking status...")
complete, err = o.checkCreateAccountAssignmentStatus(waitCtx, attemptLogger, createOut.AccountAssignmentCreationStatus)

Choose a reason for hiding this comment

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

Can we actually use complete to determine the grant status? If grant failed, completed is true, does the UI update properly that grant failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if it fails, completed is true, but we also return an error indicating that it failed, so we'd return immediately.

@jirwin jirwin merged commit 6dde690 into main Jan 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants