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

common: use regional STS on non-default regions #479

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lbajolet-hashicorp
Copy link
Contributor

STS is the service used by AWS for emitting authentication tokens for API clients.

This comes in two variants: v1 (global) and v2 (regional). As of today (2024-04-24), the default for the Go SDK is "legacy", i.e. if the connection is used to communicate with a non-default region it will use a regional endpoint, otherwise it'll use the global endpoint.

Builds are generally not affected by operations like these as the SDK will pick the right type of endpoint for that, but problems may arise later, when copying AMIs for example, as they will need tokens compatible with both the source and destination regions.

This means that if the build was performed in a default region, then copied to a non-default region, we'll have gotten a v1 (global) token, which will be rejected by the target region, causing the build to fail.

This is already fixable by user-action, through either a setting in their AWS config file, or through an environment variable, but this may come as a surprise if users aren't aware of that pitfall.

Therefore, this commit attempts to heuristically determine if an action may fail in the process, and enable regional endpoints for the EC2 session we create during a build.

Note: the volume builder and the post-processor are not affected by this, as they only work within one region at a time, so the SDK will choose the right type of endpoint/token for the action, and no cross-region action will be done.

Closes #469

@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner April 24, 2024 14:32
@lbajolet-hashicorp
Copy link
Contributor Author

Note: before merging this one, I'd like to make sure that it solves the issue at hand, and that we don't accidently break something (unlikely tbh, but I cannot be sure).

@williamb1024 may I ask you to test this version of the plugin before we can merge/release it? I believe this should fix the issue, but I couldn't test it for now since I don't have access to non-default regions (I'll have to see with who manages the AWS account for access, then will add an acceptance test later on).

@lbajolet-hashicorp lbajolet-hashicorp marked this pull request as draft April 24, 2024 14:35
STS is the service used by AWS for emitting authentication tokens for
API clients.

This comes in two variants: v1 (global) and v2 (regional).
As of today (2024-04-24), the default for the Go SDK is "legacy", i.e.
if the connection is used to communicate with a non-default region it
will use a regional endpoint, otherwise it'll use the global endpoint.

Builds are generally not affected by operations like these as the SDK
will pick the right type of endpoint for that, but problems may arise
later, when copying AMIs for example, as they will need tokens
compatible with both the source and destination regions.

This means that if the build was performed in a default region, then
copied to a non-default region, we'll have gotten a v1 (global) token,
which will be rejected by the target region, causing the build to fail.

This is already fixable by user-action, through either a setting in
their AWS config file, or through an environment variable, but this may
come as a surprise if users aren't aware of that pitfall.

Therefore, this commit attempts to heuristically determine if an action
may fail in the process, and enable regional endpoints for the EC2
session we create during a build.

Note: the volume builder and the post-processor are not affected by
this, as they only work within one region at a time, so the SDK will
choose the right type of endpoint/token for the action, and no
cross-region action will be done.
@lbajolet-hashicorp lbajolet-hashicorp force-pushed the enable_sts_v2_for_cross_region_operations branch from a15d4c2 to 8afb1fc Compare April 24, 2024 14:36
@williamb1024
Copy link
Contributor

I believe you meant @william00179

@lbajolet-hashicorp
Copy link
Contributor Author

Oh. My bad @williamb1024, wrong William indeed, sorry about the unwarranted ping.

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

Successfully merging this pull request may close these issues.

Unable to copy images to non-default regions with AssumeRole
2 participants