-
Notifications
You must be signed in to change notification settings - Fork 222
Fix AWS Region with Default region #478
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -227,8 +227,6 @@ func resolveLocalAnd1PasswordConfigurations(itemFields map[sdk.FieldName]string, | ||||||||||||||||||||||||||
region = defaultRegion | |||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
hasRegion := hasDefaultRegion || hasRegularRegion | |||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
// only 1Password OTPs are supported | |||||||||||||||||||||||||||
if awsConfig.MfaToken != "" || awsConfig.MfaProcess != "" || awsConfig.MfaPromptMethod != "" { | |||||||||||||||||||||||||||
return fmt.Errorf("only 1Password-backed OTP authentication is supported by the MFA worklfow of the AWS shell plugin") | |||||||||||||||||||||||||||
|
@@ -250,8 +248,8 @@ Learn how to add an OTP field to your item: | ||||||||||||||||||||||||||
https://developer.1password.com/docs/cli/shell-plugins/aws/#optional-set-up-multi-factor-authentication`, awsConfig.MfaSerial) | |||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
if hasRegion && awsConfig.Region != "" && region != awsConfig.Region { | |||||||||||||||||||||||||||
return fmt.Errorf("your local AWS configuration (config file or environment variable) has a different default region than the one specified in 1Password") | |||||||||||||||||||||||||||
if hasRegularRegion && awsConfig.Region != "" && region != awsConfig.Region { | |||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks backwards incompatible to me. What we're trying to achieve is the following:
Out of these the following scenario seems to fail now:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this table explains it better in terms of the expected order of precedence:
Out of these 4 cases, the second one doesn't work as expected with the current changes. Are there any other scenarios that you're thinking of that should be covered by this PR in terms of order of precendence? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, getting back to this as I have been a bit swamped at work lately, and as you will probably notice below... it isn't a simple "one line" response to your answer...
So, this is where I have disagreement, though, recognize it has a nuanced take, and won't die on a hill over it. However, I think it is worth stating all the facts before making a decision. To start, what is currently in place is wrong: treating "region" and "default region" as the same, when "default region" should only be used to in absence of a In addition, up in the test file you say this:
about this change: description: "has region both in 1Password and local config, but values differ",
itemFields: map[sdk.FieldName]string{
fieldname.OneTimePassword: "515467",
- fieldname.DefaultRegion: "us-east-2",
+- fieldname.Region: "us-east-2", I personally take issue with it for two reasons:
And to be clear, I should write another test case in addition to what was already there, but when I original was writing this up (9 months ago at this point), I was having trouble getting specs working locally, so I sorta gave up... but I will add another test once we decide on the So regarding the existing
I think the first 3 links are the most useful for trying to understand the general patterns across the CLI and all of the SDKs AWS provides, but from what I found, the description in the Ruby (my main language, so also am most comfortable with it) was the most concise example for an SDK. Generally speaking, region precedence is derived in this order of priority of
Of note is the The following example can be used as an example explain a bunch of different scenarios (though, I don't think it is exhaustive):
$ aws sts get-caller-identity --debug 2>&1 | grep client_region
# sets the region to us-east-1 (from `default` profile in `~/.aws/config`)
$ AWS_REGION=us-west-1 aws sts get-caller-identity --debug 2>&1 | grep client_region
# sets the region to us-west-1 (from `AWS_REGION`)
$ AWS_DEFAULT_REGION=ca-central-1 aws sts get-caller-identity --debug 2>&1 | grep client_region
# sets the region to ca-central-1 (from `AWS_DEFAULT_REGION`)
$ AWS_DEFAULT_REGION=ca-central-1 AWS_REGION=us-west-1 aws sts get-caller-identity --debug 2>&1 | grep client_region
# sets the region to us-west-1 (from `AWS_REGION`)
$ AWS_DEFAULT_REGION=ca-central-1 aws sts get-caller-identity --profile uk --debug 2>&1 | grep client_region
# sets the region to ca-central-1 (from `AWS_DEFAULT_REGION`)
$ aws sts get-caller-identity --profile uk --debug 2>&1 | grep client_region
# sets the region to eu-west-2 (from `uk` profile in `~/.aws/config`) Again, I would personally would assume normally that Where I think a decision needs to be made is where For me personally , I think having If, instead, we are treating this more similar to Then I don't really see this having errors on around it, and it is simply a backup or initial setting of With Personally, I don't see any utility in having the Main point with all of this is that without defining the order of precedence, and what each of these fields are supposed to do in the context of the greater existing precedence and expectations (set by AWS), then there isn't much else that I can do here before that and we should probably define that first (ideally in the documentation). At this point, I could see what I am writing here more as the start of a GitHub Issue, which in hindsight, maybe is what I should have started with in the first place (miscalculation on the quagmire I was getting myself into I guess, so mostly self induced and a realization in hindsight). So if that makes more sense, we can do that and disregard this PR until the expectations of how this plugin should treat these fields is determined. I would say even having this discussion in regards to the documentation makes more sense, but I am not sure there is a opensource repo for me to do that against so that might not be an option. Curious on your thoughts on what makes sense going forward. Thanks. |
|||||||||||||||||||||||||||
return fmt.Errorf("your local AWS configuration (config file or environment variable) has a different region than the one specified in 1Password") | |||||||||||||||||||||||||||
} else if awsConfig.Region == "" { | |||||||||||||||||||||||||||
awsConfig.Region = region | |||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of changing this test, can you add a new one in which the Region is configurerd? In this way, we ensure that this change is backwards compatible.