-
Notifications
You must be signed in to change notification settings - Fork 1.4k
pkg/asset/installconfig: Pull AWS region default from usual places #688
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
pkg/asset/installconfig: Pull AWS region default from usual places #688
Conversation
Keep setting the existing OPENSHIFT_INSTALL_AWS_REGION for now, but set the stage for the installer switching to the more widely-used variable (openshift/installer#688).
6c742d2
to
ca6f931
Compare
ca6f931
to
ed50028
Compare
pkg/asset/installconfig/aws/aws.go
Outdated
@@ -53,6 +55,24 @@ func Platform() (*aws.Platform, error) { | |||
regionTransform := survey.TransformString(func(s string) string { | |||
return strings.SplitN(s, " ", 2)[0] | |||
}) | |||
|
|||
defaultRegion := "us-east-1" | |||
var defaultRegionName string |
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.
Should we assign this as well, in case defaultRegionPointer
is nil?
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.
Should we assign this as well, in case
defaultRegionPointer
is nil?
I've pushed ed50028 -> 9dec9df, which takes a slightly different approach, but should address your point.
ed50028
to
9dec9df
Compare
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.
One nit.
/approve
pkg/asset/installconfig/aws/aws.go
Outdated
defaultRegion := "us-east-1" | ||
_, ok := validAWSRegions[defaultRegion] | ||
if !ok { | ||
return nil, errors.Errorf("installer bug: invalid default AWS region %q", defaultRegion) |
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.
I think a panic is appropriate here.
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.
I think a panic is appropriate here.
Done with 9dec9df -> 3325a68.
The AWS_DEFAULT_REGION environment variable is widely supported, e.g. by the AWS command line [1], the AWS Go library [2], and Terraform [3]. The usual AWS configuration also supplies other ways to declare a default region (e.g. ~/.aws/config [4,5]). With this commit, we check those locations instead of assuming us-east-1. We'll still prompt the user to confirm. Personally, I'd have preferred treating AWS_DEFAULT_REGION as a strong enough choice to not need confirmation, but Abhinav wanted to prompt for that case too [6]. This change is similar to, but slightly less of a slam-dunk than, 850f729 (pkg/tfvars: Drop AWS.Profile, 2018-10-15), because I haven't gotten us out of the region business entirely. Maybe we'll add multi-region support or something in the future, and then being explicit about the regions will be necessary (because there are no multi-region config conventions that I know of). [1]: https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html [2]: https://godoc.org/github.com/aws/aws-sdk-go/aws/session#hdr-Environment_Variables [3]: https://www.terraform.io/docs/providers/aws/#environment-variables [4]: https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html [5]: https://godoc.org/github.com/aws/aws-sdk-go/aws/session#hdr-Creating_Sessions [6]: openshift#688 (comment)
9dec9df
to
3325a68
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crawford, wking The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I'll try and teack that |
I suspect this is buggy. |
/retest |
The
AWS_DEFAULT_REGION
environment variable is widely supported, e.g. by the AWS command line, the AWS Go library, and Terraform. By dropping our custom environment variable in favor of the common one, we make life easier on users who may already haveAWS_DEFAULT_REGION
configured for one of the non-installer consumers.The usual AWS configuration also supplies other ways to declare a default region (e.g.
~/.aws/config
here and here). With this commit, we check those locations instead of assumingus-east-1
. In most cases, we still prompt the user to confirm, but we treat theAWS_DEFAULT_REGION
case as already-chosen and skip the prompt.If we want this, we'll need to land openshift/release#2152 first.
This is related to, but not quite the same as, when we dropped the profile config in #466.