Skip to content

Commit

Permalink
feat: multi input file support (#214)
Browse files Browse the repository at this point in the history
# Pull Request

## Description

Support for multiple input files that get merged together.

Docs updates for new version of complete-multi-region Terraform module.

Associated PR for starter module:
Azure/alz-terraform-accelerator#175

## License

By submitting this pull request, I confirm that my contribution is made
under the terms of the projects associated license.
  • Loading branch information
jaredfholgate authored Oct 8, 2024
1 parent 7f7a216 commit 31c701e
Show file tree
Hide file tree
Showing 19 changed files with 714 additions and 69 deletions.
19 changes: 16 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform-complete-multi-reg
Copy-Item -Path "$exampleFolder/inputs-github-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-terraform-complete-multi-region.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force
$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/starter-module-config/complete-multi-region"
Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-multi-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-hub-and-spoke-vnet-single-region.yaml" -Destination "$terraformConfigFolder/config-hub-and-spoke-vnet-single-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-virtual-wan-multi-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-multi-region.yaml" -Force
Copy-Item -Path "$exampleFolder/config-virtual-wan-single-region.yaml" -Destination "$terraformConfigFolder/config-virtual-wan-single-region.yaml" -Force
```

>IMPORTANT! - Now you'll need to update the input files with your settings for VCS, etc.
Expand Down Expand Up @@ -197,12 +204,14 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/azuredevops" `
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-azuredevops.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-verbose `
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
```

>NOTE: The `config-hub-and-spoke-vnet-multi-region.yaml` file is an example. You can use any of the other configuration files.
### Terraform GitHub

Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
Expand All @@ -221,12 +230,14 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/github" `
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-github.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-verbose `
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
```

>NOTE: The `config-hub-and-spoke-vnet-multi-region.yaml` file is an example. You can use any of the other configuration files.
### Terraform Local

Run this from the VSCode terminal for the ALZ-PowerShell-Module repository:
Expand All @@ -245,8 +256,10 @@ Deploy-Accelerator `
-bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" `
-starterModuleOverrideFolderPath "/$targetFolder/code/alz-terraform-accelerator/templates" `
-output "/$targetFolder/acc/terraform/output/local" `
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml" `
-inputs "/$targetFolder/acc/terraform/config/inputs-local.yaml", "/$targetFolder/acc/terraform/config/config-hub-and-spoke-vnet-multi-region.yaml" `
-verbose `
-replaceFiles # This will replace the files in the output folder with the files in the bootstrap and starter modules, so any updates are taken into account
```

>NOTE: The `config-hub-and-spoke-vnet-multi-region.yaml` file is an example. You can use any of the other configuration files.
6 changes: 4 additions & 2 deletions docs/wiki/[User-Guide]-Quick-Start-Phase-2-Azure-DevOps.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
- [Terraform Complete Starter Module][wiki_starter_module_terraform_complete]: Management groups, policies, hub networking with fully custom configuration.
1. In your PowerShell Core (pwsh) terminal run the module:
>NOTE: The following examples include 2 input files. This is the recommended approach for the `complete_multi_region` starter module. However, all inputs can be combined into a single file if desired and other starter modules only require a single input file.
```pwsh
# Windows (adjust the paths to match your setup)
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output"
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml", "c:\accelerator\config\networking.yaml" -output "c:\accelerator\output"
```
```pwsh
# Linux/Mac (adjust the paths to match your setup)
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml" -output "/accelerator/output"
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml", "/accelerator/config/networking.yaml" -output "/accelerator/output"
```
1. You will see a Terraform `init` and `apply` happen.
Expand Down
8 changes: 6 additions & 2 deletions docs/wiki/[User-Guide]-Quick-Start-Phase-2-GitHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,16 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
- [Terraform Complete Starter Module][wiki_starter_module_terraform_complete]: Management groups, policies, hub networking with fully custom configuration.
1. In your PowerShell Core (pwsh) terminal run the module:
>NOTE: The following examples include 2 input files. This is the recommended approach for the `complete_multi_region` starter module. However, all inputs can be combined into a single file if desired and other starter modules only require a single input file.
```pwsh
# Windows (adjust the paths to match your setup)
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output"
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml", "c:\accelerator\config\networking.yaml" -output "c:\accelerator\output"
```
```pwsh
# Linux/Mac (adjust the paths to match your setup)
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml" -output "/accelerator/output"
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml", "/accelerator/config/networking.yaml" -output "/accelerator/output"
```
1. You will see a Terraform `init` and `apply` happen.
Expand Down
6 changes: 4 additions & 2 deletions docs/wiki/[User-Guide]-Quick-Start-Phase-2-Local.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
- [Terraform Complete Starter Module][wiki_starter_module_terraform_complete]: Management groups, policies, hub networking with fully custom configuration.
1. In your PowerShell Core (pwsh) terminal run the module:
>NOTE: The following examples include 2 input files. This is the recommended approach for the `complete_multi_region` starter module. However, all inputs can be combined into a single file if desired and other starter modules only require a single input file.
```pwsh
# Windows (adjust the paths to match your setup)
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output"
Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml", "c:\accelerator\config\networking.yaml" -output "c:\accelerator\output"
```
```pwsh
# Linux/Mac (adjust the paths to match your setup)
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml" -output "/accelerator/output"
Deploy-Accelerator -inputs "/accelerator/config/inputs.yaml", "/accelerator/config/networking.yaml" -output "/accelerator/output"
```
1. You will see a Terraform `init` and `apply` happen.
Expand Down
21 changes: 14 additions & 7 deletions docs/wiki/[User-Guide]-Quick-Start-Phase-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Follow the steps below to deploy the landing zone locally. If you want to hook i

#### 3.1.3.1 Bicep

The Bicep option outputs a `deploy-local.ps1` file that you can use to deploy the ALZ.

>NOTE: If you set the `grant_permissions_to_current_user` input to `false` in the bootstrap, you will need to set permissions on your management group and subscriptions before the commands will succeed.
1. Ensure you have the latest versions of the [AZ PowerShell Module](https://learn.microsoft.com/en-us/powershell/azure/install-azure-powershell) and [Bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) installed.
1. Open a new PowerShell Core (pwsh) terminal or use the one you already have open.
1. Navigate to the directory shown in the `module_output_directory_path` output from the bootstrap.
Expand All @@ -49,13 +53,16 @@ Follow the steps below to deploy the landing zone locally. If you want to hook i

#### 3.1.3.2 Terraform

The Terraform option outputs a `deploy-local.ps1` file that you can use to deploy the ALZ.

>NOTE: If you set the `grant_permissions_to_current_user` input to `false` in the bootstrap, you will need to set permissions on your management group, subscriptions and storage account before the commands will succeed.
1. Open a new PowerShell Core (pwsh) terminal or use the one you already have open.
1. Navigate to the directory shown in the `module_output_directory_path` output from the bootstrap.
1. If you choose to deploy the bootstrap resources in Azure, then you will need to navigate to the Azure Portal and find you storage account.
1. Make note of the `Resource Group Name`, `Storage account name`and `Container Name` from the storage account.
1. If you did not choose to deploy the bootstrap resources in Azure, type `terraform init` and hit enter.
1. If you choose to deploy the bootstrap resources in Azure, type `terraform init -backend-config="resource_group_name=<Resource Group Name>" -backend-config="storage_account_name=<Storage account name>" -backend-config="container_name=<Container Name>" -backend-config="key=terraform.tfstate" -backend-config="use_azuread_auth=true"` , replacing the items in angle brackets and hit enter.
1. Type `terraform plan -out=tfplan` and hit enter.
1. Review the plan. Use `terraform show tfplan` to see the plan details.
1. If you are happy with the plan, then type `terraform apply tfplan` and hit enter.
1. (Optional) Ensure you are still logged in to Azure using `az login --tenant 00000000-0000-0000-0000-000000000000`.
1. (Optional) Connect to your target subscription using `az account set --subscription 00000000-0000-0000-0000-000000000000`.
1. (Optional) Examine the `./scripts/deploy-local.ps1` to understand what it is doing.
1. Run `./scripts/deploy-local.ps1`.
1. A plan will run and then you'll be prompted to check it and run the deploy.
1. Type `yes` and hit enter to run the deploy.
1. The ALZ will now be deployed, this may take some time.
Loading

0 comments on commit 31c701e

Please sign in to comment.