You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Pull Request
## Issue
Issue #, if available:
https://github.com/Azure/alz-terraform-accelerator/issues/70
## Description
Description of changes:
This PR adds re-run, upgrade and destroy features for Terraform. These
features are designed to simplify usage of the accelerator, provide any
easy way to apply changes, fix issues and upgrade to a newer version.
The destroy will make it much easier to clean up test environments.
## License
By submitting this pull request, I confirm that my contribution is made
under the terms of the projects associated license.
# If the current version has already been run, then skip the upgrade process
54
+
break
55
+
}
56
+
57
+
$foundPreviousRelease=$true
58
+
$previousVersion=$directory.Name
59
+
break
60
+
}
61
+
}
62
+
63
+
if($foundPreviousRelease) {
64
+
Write-InformationColored"AUTOMATIC UPGRADE: We found version $previousVersion that has been previously run. You can upgrade from this version to the new version $currentVersion"-ForegroundColor Yellow -InformationAction Continue
65
+
$upgrade=""
66
+
if($autoApprove) {
67
+
$upgrade="upgrade"
68
+
} else {
69
+
$upgrade=Read-Host"If you would like to upgrade, enter 'upgrade' or just hit 'enter' to continue with a new environment. (upgrade/exit)"
# Copy the previous cached values to the current release
79
+
if($null-ne$previousBootstrapCachedValuesPath) {
80
+
Write-InformationColored"AUTOMATIC UPGRADE: Copying $previousBootstrapCachedValuesPath to $currentBootstrapCachedValuesPath"-ForegroundColor Green -InformationAction Continue
Write-InformationColored"AUTOMATIC UPGRADE: Copying $previousStarterCachedValuesPath to $currentStarterCachedValuesPath"-ForegroundColor Green -InformationAction Continue
Write-InformationColored"AUTOMATIC UPGRADE: Upgrade complete. If any files in the starter have been updated, you will need to remove branch protection in order for the Terraform apply to succeed..."-ForegroundColor Yellow -InformationAction Continue
@@ -52,8 +65,12 @@ function New-ALZEnvironmentTerraform {
52
65
53
66
Write-InformationColored"Got configuration and downloaded alz-terraform-accelerator Terraform module version $releaseTag to $alzEnvironmentDestination"-ForegroundColor Green -InformationAction Continue
54
67
68
+
#Checking for cached bootstrap values for retry / upgrade scenarios
@@ -63,8 +80,13 @@ function New-ALZEnvironmentTerraform {
63
80
64
81
Write-InformationColored"The following inputs are specific to the '$starterTemplate' starter module that you selected..."-ForegroundColor Green -InformationAction Continue
65
82
83
+
# Checking for cached starter module values for retry / upgrade scenarios
Write-InformationColored"Thank you for providing those inputs, we are now initializing and applying Terraform to bootstrap your environment..."-ForegroundColor Green -InformationAction Continue
Write-InformationColored"Once the plan is complete you will be prompted to confirm the apply. You must enter 'yes' to apply."-ForegroundColor Green -InformationAction Continue
Write-InformationColored"We found you have cached values from a previous run."-ForegroundColor Yellow -InformationAction Continue
34
+
$useDefaults=""
35
+
if($autoApprove) {
36
+
$useDefaults="use"
37
+
} else {
38
+
$useDefaults=Read-Host"Would you like to use these values or see each of them to validate and change them? Enter 'use' to use the cached value or just hit 'enter' to see and validate each value. (use/see)"
39
+
}
40
+
if($useDefaults.ToLower() -eq"use") {
41
+
$userInputOverrides=$userInputDefaultOverrides
42
+
}
43
+
}
44
+
26
45
$hasInputOverrides=$false
27
46
if($userInputOverrides-ne$null) {
28
47
$hasInputOverrides=$true
@@ -34,6 +53,20 @@ function Request-ALZEnvironmentConfig {
34
53
35
54
foreach ($configurationValuein$configurations) {
36
55
if ($configurationValue.Value.Type-eq"UserInput") {
Copy file name to clipboardExpand all lines: src/ALZ/Public/New-ALZEnvironment.ps1
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,8 @@ function New-ALZEnvironment {
16
16
A json file containing user input overrides for the user input prompts. This will cause the tool to by pass requesting user input for that field and use the value(s) provided. E.g { "starter_module": "basic", "azure_location": "uksouth" }
17
17
.PARAMETERautoApprove
18
18
Automatically approve the terraform apply.
19
+
.PARAMETERdestroy
20
+
Destroy the terraform environment.
19
21
.EXAMPLE
20
22
New-ALZEnvironment
21
23
.EXAMPLE
@@ -56,7 +58,10 @@ function New-ALZEnvironment {
56
58
[string] $userInputOverridePath="",
57
59
58
60
[Parameter(Mandatory=$false)]
59
-
[switch] $autoApprove
61
+
[switch] $autoApprove,
62
+
63
+
[Parameter(Mandatory=$false)]
64
+
[switch] $destroy
60
65
)
61
66
62
67
Write-InformationColored"Getting ready to create a new ALZ environment with you..."-ForegroundColor Green -InformationAction Continue
0 commit comments