Skip to content

fix(storage): AWS Dynamic Credentials (Assume Role)#33

Merged
hugoghx merged 2 commits into
ddebko-fix-assume-rolefrom
hugo-assume-role
Sep 21, 2023
Merged

fix(storage): AWS Dynamic Credentials (Assume Role)#33
hugoghx merged 2 commits into
ddebko-fix-assume-rolefrom
hugo-assume-role

Conversation

@hugoghx
Copy link
Copy Markdown
Contributor

@hugoghx hugoghx commented Sep 11, 2023

This PR introduces fixes to enable operators to use AWS dynamic credentials on the storage side of this plugin, namely validation, improved credential lifecycle management to allow for storage buckets to be updated from static to dynamic credentials and vice versa, and a new way to determine credential types.

It also introduces new tests for dynamic credential usage for the various functions.

Finally, it also fixes a problem with static rotated credentials being deleted from AWS when the plugin errored due to lack of validation

@hugoghx hugoghx self-assigned this Sep 11, 2023
@hugoghx hugoghx requested review from ddebko and louisruch September 11, 2023 13:18
@hugoghx hugoghx force-pushed the hugo-assume-role branch 3 times, most recently from 1155af2 to e908091 Compare September 13, 2023 11:04
@hugoghx hugoghx marked this pull request as ready for review September 18, 2023 14:34
@hugoghx

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@ddebko ddebko left a comment

Choose a reason for hiding this comment

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

This looks great. I think there is one edge case we didn't cover for updating a storage bucket, which is deleting the old bucket's static credentials that we are managing with credential rotation. This should be done after we have checked that the new credentials dry run validation has passed and we have confirmed that the keys can be rotated if credential rotation is enabled.

Comment thread internal/credential/attributes.go Outdated
Comment thread internal/credential/state.go Outdated
Comment thread internal/credential/state.go
Comment thread internal/credential/state.go Outdated
Comment thread plugin/service/storage/plugin.go
Comment thread internal/credential/attributes.go
StaticOther

// Unknown is a catch-all for everything else.
Unknown
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What would the behavior of unknown be?

Copy link
Copy Markdown
Contributor Author

@hugoghx hugoghx Sep 19, 2023

Choose a reason for hiding this comment

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

For the most part, it's used to carve out a special condition (eg: ToMap), fast-track the env variables use case, or an error, since we don't really know what it is.

Comment on lines +34 to +36
// StaticOther denotes the presence of an Access Key Id that does not follow
// the AKIA/ASIA convention outlined by AWS.
StaticOther
Copy link
Copy Markdown
Contributor

@kheina kheina Sep 20, 2023

Choose a reason for hiding this comment

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

I am curious if this could ever cause problems if returned by GetCredentialType since there are a few checks for StaticAWS specifically, or is this just for service providers other than AWS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

or is this just for service providers other than AWS?

Yep, this is exactly what it is for - StaticAWS uses the hard-coded AWS conventions, and then everything else that doesn't follow that is StaticOther, for S3-Compatible... compatibility 😂

Copy link
Copy Markdown
Contributor

@ddebko ddebko Sep 20, 2023

Choose a reason for hiding this comment

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

Have we tested a S3 compatible service with these code changes? Other than aws S3.

Copy link
Copy Markdown
Contributor Author

@hugoghx hugoghx Sep 20, 2023

Choose a reason for hiding this comment

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

I have not - I think that's outside the scope of this work since this patch isn't really about enabling S3-compatible services. The StaticOther credential type is introduced here more as a way of keeping that path open for future S3-Compatibility work and not shoot ourselves in the foot.

I might spin up a MinIO instance and give it a quick shot though 😄

Copy link
Copy Markdown
Contributor

@ddebko ddebko left a comment

Choose a reason for hiding this comment

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

I'm happy to approve this PR as long as we have a follow up task for a later date to resolve the issue of orphaned secrets that boundary manages when invoking update storage bucket.

@hugoghx
Copy link
Copy Markdown
Contributor Author

hugoghx commented Sep 20, 2023

I'm happy to approve this PR as long as we have a follow up task for a later date to resolve the issue of orphaned secrets that boundary manages when invoking update storage bucket.

Yep, that's already set-up :)

@hugoghx
Copy link
Copy Markdown
Contributor Author

hugoghx commented Sep 21, 2023

Merging this PR onto ddebko-fix-assume-role. For any new/ongoing discussions, please post in #34 instead

Hugo added 2 commits September 21, 2023 18:43
This commit introduces fixes to enable operators to use AWS dynamic
credentials on the storage side of this plugin, namely validation,
improved credential lifecycle management to allow for storage buckets to
be updated from static to dynamic credentials and vice versa, and a new
way to determine credential types.

It also introduces new tests for dynamic credential usage for the
various functions.
On Storage Bucket update, when we determine if the credentials are to be
updated to new ones, we call `credState.ReplaceCreds`.

This call, if the old credentials were managed by us (rotated at create
time), will delete the old credentials and set the new ones onto
credState.

We called this function without validating if the incoming credentials
are valid. This could get the bucket in a state where where, while we'd
return an update error if the incoming credentials weren't working with
S3 (err in the dry run process that happens at the end of the update),
we'd also silently delete the old credentials the bucket used, rendering
the bucket completely broken.
@hugoghx hugoghx merged commit a0f070e into ddebko-fix-assume-role Sep 21, 2023
@hugoghx hugoghx deleted the hugo-assume-role branch September 21, 2023 18:08
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.

4 participants