Skip to content

Commit

Permalink
feat: improvements to inputs and region validation (#182)
Browse files Browse the repository at this point in the history
# Pull Request

## Issues

#124 

## Description

This PR adds a few improvements:

- The regions and availability zones are now retrieved dynamically.
- The PowerShell module supports overriding the bootstrap
terraform.tfvars file as one method of supplying values for hidden
variables.
- The PowerShell module supports supplying hidden bootstrap variables
via the inputs config file, for example resource names can now be
supplied there.
- The override.tfvars file is now in json format, so we can support
complex data types.

e2e test run:
https://github.com/Azure/accelerator-bootstrap-modules/actions/runs/10734976021

## 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 Sep 6, 2024
1 parent 795dcbb commit aa0f60e
Show file tree
Hide file tree
Showing 28 changed files with 414 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MD004: false # ul-style - Unordered list style
MD007:
indent: 2 # ul-indent - Unordered list indentation
MD013:
line_length: 500 # line-length - Line length
line_length: 600 # line-length - Line length
MD026:
punctuation: ".,;:!。,;:" # no-trailing-punctuation - Trailing punctuation in heading
MD029: false # ol-prefix - Ordered list item prefix
Expand Down
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ Example folder structure:
┗ 📂acc
┣ 📂bicep
┃ ┣ 📂config
┃ ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep.yaml
┃ ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-bicep.yaml
┃ ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-bicep.yaml
┃ ┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml
┃ ┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml
┃ ┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml
┃ ┗ 📂output
┃ ┣ 📂azuredevops
┃ ┣ 📂github
┃ ┗ 📂local
┗ 📂terraform
┣ 📂config
┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform.yaml
┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-terraform.yaml
┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-terraform.yaml
┃ ┣ 📜inputs-azuredevops.yaml # ./docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml
┃ ┣ 📜inputs-github.yaml # ./docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml
┃ ┗ 📜inputs-local.yaml # ./docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml
┗ 📂output
┣ 📂azuredevops
┣ 📂github
Expand Down Expand Up @@ -94,12 +94,12 @@ cd /
$exampleFolder = "$targetFolder/code/ALZ-PowerShell-Module/docs/wiki/examples/powershell-inputs"
Copy-Item -Path "$exampleFolder/inputs-azure-devops-bicep.yaml" -Destination "$bicepConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-bicep.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-bicep.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform.yaml" -Destination "$terraformConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-terraform.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-terraform.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-azure-devops-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-bicep-complete.yaml" -Destination "$bicepConfigFolder/inputs-local.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-azure-devops-terraform-complete.yaml" -Destination "$terraformConfigFolder/inputs-azuredevops.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-github-terraform-complete.yaml" -Destination "$terraformConfigFolder/inputs-github.yaml" -Force
Copy-Item -Path "$exampleFolder/inputs-local-terraform-complete.yaml" -Destination "$terraformConfigFolder/inputs-local.yaml" -Force
```

Expand Down
52 changes: 43 additions & 9 deletions docs/wiki/Frequently-Asked-Questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,51 @@ This article answers frequently asked questions relating to the Azure landing zo

### How do I use my own naming convention for the resources that are deployed?

Follow these steps to customise the resource names:
You can add any hidden variables to your inputs file, including the `resource_names` map. This map is used to set the names of the resources that are deployed. You can find the default values in the `terraform.tfvars` file in the bootstrap module.

1. At step 2.2 of the quickstart, you will run the `Deploy-Accelerator` command to start the user input process.
1. Once the prompt appears for the first question open the relevant bootstrap `terraform.tfvars` file:
1. Azure DevOps: `./bootstrap/v#.#.#/alz/azuredevops/terraform.tfvars`
1. GitHub: `./bootstrap/v#.#.#/alz/github/terraform.tfvars`
1. Look for the variable called `resource_names`.
1. Update this map to have the names you desire and save it.
1. Continue with the user input as normal.
For example adding this to the end of your inputs file and updating to your standard:

You'll now get the names you specified instead of the default ones.
```yaml
# Extra Inputs
resource_names:
resource_group_state: "rg-{{service_name}}-{{environment_name}}-state-{{azure_location}}-{{postfix_number}}-test"
resource_group_identity: "rg-{{service_name}}-{{environment_name}}-identity-{{azure_location}}-{{postfix_number}}"
resource_group_agents: "rg-{{service_name}}-{{environment_name}}-agents-{{azure_location}}-{{postfix_number}}"
resource_group_network: "rg-{{service_name}}-{{environment_name}}-network-{{azure_location}}-{{postfix_number}}"
user_assigned_managed_identity_plan: "id-{{service_name}}-{{environment_name}}-{{azure_location}}-plan-{{postfix_number}}"
user_assigned_managed_identity_apply: "id-{{service_name}}-{{environment_name}}-{{azure_location}}-apply-{{postfix_number}}"
user_assigned_managed_identity_federated_credentials_plan: "id-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}-plan"
user_assigned_managed_identity_federated_credentials_apply: "id-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}-apply"
storage_account: "sto{{service_name_short}}{{environment_name_short}}{{azure_location_short}}{{postfix_number}}{{random_string}}"
storage_container: "{{environment_name}}-tfstate"
container_instance_01: "aci-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}"
container_instance_02: "aci-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number_plus_1}}"
container_instance_managed_identity: "id-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}-aci"
agent_01: "agent-{{service_name}}-{{environment_name}}-{{postfix_number}}"
agent_02: "agent-{{service_name}}-{{environment_name}}-{{postfix_number_plus_1}}"
version_control_system_repository: "{{service_name}}-{{environment_name}}"
version_control_system_repository_templates: "{{service_name}}-{{environment_name}}-templates"
version_control_system_service_connection_plan: "sc-{{service_name}}-{{environment_name}}-plan"
version_control_system_service_connection_apply: "sc-{{service_name}}-{{environment_name}}-apply"
version_control_system_environment_plan: "{{service_name}}-{{environment_name}}-plan"
version_control_system_environment_apply: "{{service_name}}-{{environment_name}}-apply"
version_control_system_variable_group: "{{service_name}}-{{environment_name}}"
version_control_system_agent_pool: "{{service_name}}-{{environment_name}}"
version_control_system_group: "{{service_name}}-{{environment_name}}-approvers"
version_control_system_pipeline_name_ci: "01 Azure Landing Zones Continuous Integration"
version_control_system_pipeline_name_cd: "02 Azure Landing Zones Continuous Delivery"
virtual_network: "vnet-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}"
public_ip: "pip-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}"
nat_gateway: "nat-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}"
subnet_container_instances: "subnet-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}-aci"
subnet_private_endpoints: "subnet-{{service_name}}-{{environment_name}}-{{azure_location}}-{{postfix_number}}-pe"
storage_account_private_endpoint: "pe-{{service_name}}-{{environment_name}}-{{azure_location}}-sto-{{postfix_number}}"
container_registry: "acr{{service_name}}{{environment_name}}{{azure_location_short}}{{postfix_number}}{{random_string}}"
container_registry_private_endpoint: "pe-{{service_name}}-{{environment_name}}-{{azure_location}}-acr-{{postfix_number}}"
container_image_name: "azure-devops-agent"
```
Alternatively, you can take a copy of the `terraform.tfvars` file from the bootstrap module, update it and supply it via the `-bootstrapTfVarsOverridePath` parameter as an absolute path.

## Questions about bootstrap clean up

Expand Down
4 changes: 2 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 @@ -59,7 +59,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
| `use_self_hosted_agents` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. |
| `use_private_networking` | `true` | This controls whether private networking is deployed for your self-hosted agents and storage account. This only applies if you have `use_self_hosted_agents` set to `true`. This defaults to `true`. |
| `allow_storage_access_from_my_ip` | `false` | This is not relecant to Bicep and we'll remove the need to specify it later, leave it set to `false`. |
| `apply_approvers` | `<email-address-list>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is a comma-separated list like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty string `""` to disable approvals. |
| `apply_approvers` | `<email-address>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is an array of strings like `["abc@xyz.com", "def@xyz.com", "ghi@xyz.com"]`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty array `[]` to disable approvals. Note if supplying via the user interface, use a comma separated string like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. |
| `create_branch_policies` | `true` | This controls whether to create branch policies for the repository. This defaults to `true`. |
1. Now head over to your chosen starter module documentation to get the specific inputs for that module. Come back here when you are done.
Expand Down Expand Up @@ -137,7 +137,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
| `use_self_hosted_agents` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. |
| `use_private_networking` | `true` | This controls whether private networking is deployed for your self-hosted agents and storage account. This only applies if you have `use_self_hosted_agents` set to `true`. This defaults to `true`. |
| `allow_storage_access_from_my_ip` | `false` | This controls whether to allow access to the storage account from your IP address. This is only needed for trouble shooting. This only applies if you have `use_private_networking` set to `true`. This defaults to `false`. |
| `apply_approvers` | `<email-address-list>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is a comma-separated list like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty string `""` to disable approvals. |
| `apply_approvers` | `<email-address>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is an array of strings like `["abc@xyz.com", "def@xyz.com", "ghi@xyz.com"]`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty array `[]` to disable approvals. Note if supplying via the user interface, use a comma separated string like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. |
| `create_branch_policies` | `true` | This controls whether to create branch policies for the repository. This defaults to `true`. |
1. Now head over to your chosen starter module documentation to get the specific inputs for that module. Come back here when you are done.
Expand Down
4 changes: 2 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 @@ -53,7 +53,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
| `use_self_hosted_agents` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. |
| `use_private_networking` | `true` | This controls whether private networking is deployed for your self-hosted agents and storage account. This only applies if you have `use_self_hosted_agents` set to `true`. This defaults to `true`. |
| `allow_storage_access_from_my_ip` | `false` | This is not relevant to Bicep and we'll remove the need to specify it later, leave it set to `false`. |
| `apply_approvers` | `<email-address-list>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is a comma-separated list like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty string `""` to disable approvals. |
| `apply_approvers` | `<email-address>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is an array of strings like `["abc@xyz.com", "def@xyz.com", "ghi@xyz.com"]`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty array `[]` to disable approvals. Note if supplying via the user interface, use a comma separated string like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. |
| `create_branch_policies` | `true` | This controls whether to create branch policies for the repository. This defaults to `true`. |
1. Now head over to your chosen starter module documentation to get the specific inputs for that module. Come back here when you are done.
Expand Down Expand Up @@ -124,7 +124,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs,
| `use_self_hosted_agents` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. |
| `use_private_networking` | `true` | This controls whether private networking is deployed for your self-hosted agents and storage account. This only applies if you have `use_self_hosted_agents` set to `true`. This defaults to `true`. |
| `allow_storage_access_from_my_ip` | `false` | This controls whether to allow access to the storage account from your IP address. This is only needed for trouble shooting. This only applies if you have `use_private_networking` set to `true`. This defaults to `false`. |
| `apply_approvers` | `<email-address-list>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is a comma-separated list like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty string `""` to disable approvals. |
| `apply_approvers` | `<email-address>` | This is a list of service principal names (SPN) of people you wish to be in the group that approves apply of the Azure landing zone module. This is an array of strings like `["abc@xyz.com", "def@xyz.com", "ghi@xyz.com"]`. You may need to check what the SPN is prior to filling this out as it can vary based on identity provider. Use empty array `[]` to disable approvals. Note if supplying via the user interface, use a comma separated string like `abc@xyz.com,def@xyz.com,ghi@xyz.com`. |
| `create_branch_policies` | `true` | This controls whether to create branch policies for the repository. This defaults to `true`. |
1. Now head over to your chosen starter module documentation to get the specific inputs for that module. Come back here when you are done.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ azure_devops_project_name: "<azure-devops-project-name>"
use_self_hosted_agents: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Complete Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ azure_devops_project_name: "<azure-devops-project-name>"
use_self_hosted_agents: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Basic Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ azure_devops_project_name: "<azure-devops-project-name>"
use_self_hosted_agents: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Complete vNext Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ azure_devops_project_name: "<azure-devops-project-name>"
use_self_hosted_agents: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Complete Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ azure_devops_project_name: "<azure-devops-project-name>"
use_self_hosted_agents: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Hub Networking Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postfix_number: "1"
use_self_hosted_runners: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postfix_number: "1"
use_self_hosted_runners: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Basic Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postfix_number: "1"
use_self_hosted_runners: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Complete vNext Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postfix_number: "1"
use_self_hosted_runners: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Complete Starter Module Specific Variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postfix_number: "1"
use_self_hosted_runners: "true"
use_private_networking: "true"
allow_storage_access_from_my_ip: "false"
apply_approvers: "<email-address-list>"
apply_approvers: ["<email-address>"]
create_branch_policies: "true"

# Hub Networking Starter Module Specific Variables
Expand Down
Loading

0 comments on commit aa0f60e

Please sign in to comment.