Skip to content

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

Merged
merged 1 commit into from
Dec 6, 2018

Conversation

wking
Copy link
Member

@wking wking commented Nov 15, 2018

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 have AWS_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 assuming us-east-1. In most cases, we still prompt the user to confirm, but we treat the AWS_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.

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 15, 2018
wking added a commit to wking/openshift-release that referenced this pull request Nov 15, 2018
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).
@wking wking force-pushed the aws-default-region branch from 6c742d2 to ca6f931 Compare November 15, 2018 23:26
@wking wking force-pushed the aws-default-region branch from ca6f931 to ed50028 Compare December 5, 2018 08:35
@wking wking changed the title pkg/asset/installconfig: OPENSHIFT_INSTALL_AWS_REGION -> AWS_DEFAULT_REGION pkg/asset/installconfig: Pull AWS region default from usual places Dec 5, 2018
@@ -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
Copy link
Contributor

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?

Copy link
Member Author

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.

@wking wking force-pushed the aws-default-region branch from ed50028 to 9dec9df Compare December 6, 2018 01:00
Copy link
Contributor

@crawford crawford left a comment

Choose a reason for hiding this comment

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

One nit.

/approve

defaultRegion := "us-east-1"
_, ok := validAWSRegions[defaultRegion]
if !ok {
return nil, errors.Errorf("installer bug: invalid default AWS region %q", defaultRegion)
Copy link
Contributor

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.

Copy link
Member Author

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)
@wking wking force-pushed the aws-default-region branch from 9dec9df to 3325a68 Compare December 6, 2018 01:22
@crawford
Copy link
Contributor

crawford commented Dec 6, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 6, 2018
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wking
Copy link
Member Author

wking commented Dec 6, 2018

e2e-aws:

error: watch closed before Until timeout
error openshift-ingress/deploy/router-default did not come up
sleep: invalid option -- '4'
Try 'sleep --help' for more information.

I'll try and teack that sleep down later.

@wking
Copy link
Member Author

wking commented Dec 6, 2018

I suspect this is buggy.

@wking
Copy link
Member Author

wking commented Dec 6, 2018

/retest

@openshift-merge-robot openshift-merge-robot merged commit b4f5ceb into openshift:master Dec 6, 2018
@wking wking deleted the aws-default-region branch December 6, 2018 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants