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

validate input for Azure Region and Terraform Environment on deploy.sh and setup_ezdeploy.sh #174

Merged
merged 15 commits into from
Apr 26, 2021

Conversation

glennmusa
Copy link
Contributor

@glennmusa glennmusa commented Apr 23, 2021

Description

Today, deploy.sh and setup_ezdeploy.sh use AzureCloud-specific defaults to make it simpler for end-users to deploy. However, they A) may not know these defaults are set for them and B) these defaults may not be valid for the cloud they're deploying to.

This change:

  • catches errors where Terraform will fail at execution time for a azurerm environment + Cloud mismatch (e.g. providing "public" with cloud set to "AzureUsGovernment")
  • catches errors where MLZ Configuration will fail to provision because the specified Azure region is not valid for the contextual cloud executing the commands (e.g. providing "eastus" with cloud set to "AzureUsGovernment")
  • informs the user that defaults are being set for them and provides hints on how to override them

For example, if I set my cloud to AzureUsGovernment:

az cloud set -n AzureUsGovernment

and try to deploy using ./deploy.sh with the defaults, I'll get back these messages and this error:

~/dev/missionlz$ src/deploy.sh -s {my_omitted_subscription_id}
INFO: using the default value 'eastus' for '--location', specify the '--location' argument to provide a different value.
INFO: using the default value 'public' for '--tf-environment', specify the '--tf-environment' argument to provide a different value.
INFO: using the default value 'mlz1619186307' for '--mlz-env-name', specify the '--mlz-env-name' argument to provide a different value.
INFO: setting current subscription to {my_omitted_subscription_id}...
ERROR: could not find region 'eastus' for subscription of '{my_omitted_subscription_id}' in current cloud 'AzureUSGovernment'
INFO: is this a valid region? Try 'az account list-locations' to see what regions are available to you.
INFO: do you have the correct cloud set? Try 'az cloud set' to set it.

and if I provide a valid location, but do not provide a matching terraform environment:

~/dev/missionlz$ src/deploy.sh -s {my_omitted_subscription_id} -l usgovvirginia
INFO: using the default value 'public' for '--tf-environment', specify the '--tf-environment' argument to provide a different value.
INFO: using the default value 'mlz1619186398' for '--mlz-env-name', specify the '--mlz-env-name' argument to provide a different value.
INFO: setting current subscription to {my_omitted_subscription_id}...
ERROR: Terraform environment 'public' is not a valid environment for cloud 'AzureUSGovernment'
INFO: check the valid settings for Terraform environment here: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#environment

Issue reference

The issue this PR will close: #172, #173

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles or validates correctly
  • BASH scripts have been validated using shellcheck
  • All tests pass (manual and automated)
  • The documentation is updated to cover any new or changed features
  • Markdown files have been linted using the recommended linter. (See .vscode/extensions.json.)
  • Relevant issues are linked to this PR

glennmusa and others added 9 commits April 22, 2021 21:50
* Various fixes and refactor to allow for export and load

* Update documentation.

* Abstract export code to own file, extend to allow file names

* Fix various.

Co-authored-by: Bree Stryker <bstryker@DESKTOP-3AGKDHF.localdomain>
@glennmusa glennmusa requested a review from sstjean April 26, 2021 14:02
Copy link
Contributor

@sstjean sstjean left a comment

Choose a reason for hiding this comment

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

Code looks solid.

Successfully tested functionality against Commercial and Gov.

@glennmusa glennmusa merged commit c951807 into main Apr 26, 2021
@glennmusa glennmusa deleted the glenn/validatelocation branch April 26, 2021 21:16
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.

Inform user when defaults are used
3 participants