diff --git a/.gitignore b/.gitignore index ef1d17bf..4eec5930 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ templates/basic/terraform.tfvars templates/.test_azuredevops templates/.test_github .vscode/settings.json +/ALZ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ffa5889..a8ac77e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -155,6 +155,30 @@ Deploy-Accelerator ` ``` +### Bicep Local + +Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: + +>IMPORTANT! - Make sure to update the input file with your settings for VCS, etc. + +```pwsh +Invoke-Build -File .\src\ALZ.build.ps1 + +$targetFolder = "dev" + +# Uncomment to start fresh rather than relying on the -replaceFiles parameter +# Remove-Item -Path "/$targetFolder/acc/bicep/output/github" -Recurse -Force + +Deploy-Accelerator ` + -bootstrapModuleOverrideFolderPath "/$targetFolder/code/accelerator-bootstrap-modules" ` + -starterModuleOverrideFolderPath "/$targetFolder/code/ALZ-Bicep" ` + -output "/$targetFolder/acc/bicep/output/local" ` + -inputs "/$targetFolder/acc/bicep/config/inputs-local.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 + +``` + ### Terraform Azure DevOps Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: @@ -202,3 +226,27 @@ Deploy-Accelerator ` -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 ``` + +### Terraform Local + +Run this from the VSCode terminal for the ALZ-PowerShell-Module repository: + +>IMPORTANT! - Make sure to update the input file with your settings for VCS, etc. + +```pwsh +Invoke-Build -File .\src\ALZ.build.ps1 + +$targetFolder = "dev" + +# Uncomment to start fresh rather than relying on the -replaceFiles parameter +# Remove-Item -Path "/$targetFolder/acc/terraform/output/azuredevops" -Recurse -Force + +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" ` + -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 + +``` diff --git a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Azure-DevOps.md b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Azure-DevOps.md index 48859a55..19c5b246 100644 --- a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Azure-DevOps.md +++ b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Azure-DevOps.md @@ -19,8 +19,8 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```pwsh # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output ``` ```plaintext @@ -33,34 +33,36 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, 1. Open your `inputs.yaml` file in Visual Studio Code (or your preferred editor) and copy the content from [inputs-azure-devops-bicep-complete.yaml][example_powershell_inputs_azure_devops_bicep_complete] into that file. 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | - | `bootstrap` | `alz_azuredevops` | This is the choice of Version Control System. Keep this as `alz_azuredevops` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `azure_devops_personal_access_token` | `` | Replace `` with the `token-1` Azure DevOps PAT you generated in a previous step. | - | `azure_devops_agents_personal_access_token` | `` | Replace `` with the `token-2` Azure DevOps PAT you generated in the previous step specifically for the self-hosted agents. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted agents. | - | `azure_devops_organization_name` | `` | Replace `` with the name of your Azure DevOps organization. This is the section of the url after `dev.azure.com` or before `.visualstudio.com`. E.g. enter `my-org` for `https://dev.azure.com/my-org`. | - | `use_separate_repository_for_templates` | `true` | Determine whether to create a separate repository to store pipeline templates as an extra layer of security. Set to `false` if you don't wish to secure your pipeline templates by using a separate repository. This will default to `true`. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | - | `azure_devops_use_organisation_legacy_url` | `false` | If you have not migrated to the modern url (still using `https://.visualstudio.com`) for your Azure DevOps organisation, then set this to `true`. | - | `azure_devops_create_project` | `true` | If you have an existing project you want to use rather than creating a new one, select `true`. We recommend creating a new project to ensure it is isolated by a strong security boundary. | - | `azure_devops_project_name` | `` | Replace `` with the name of the Azure DevOps project to create or the name of an existing project if you set `azure_devops_create_project` to `false`. | - | `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` | `` | 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`. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "bicep"` or `env:TF_VAR_azure_devops_personal_access_token = "*****..."`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_azuredevops` | This is the choice of Version Control System. Keep this as `alz_azuredevops` for this example. | + | `starter_module_name` | `ALZ` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `azure_devops_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-1` Azure DevOps PAT you generated in a previous step. | + | `azure_devops_agents_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-2` Azure DevOps PAT you generated in the previous step specifically for the self-hosted agents. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted agents. | + | `azure_devops_organization_name` | `TF_VAR` | `` | Replace `` with the name of your Azure DevOps organization. This is the section of the url after `dev.azure.com` or before `.visualstudio.com`. E.g. enter `my-org` for `https://dev.azure.com/my-org`. | + | `use_separate_repository_for_templates` | `TF_VAR` | `true` | Determine whether to create a separate repository to store pipeline templates as an extra layer of security. Set to `false` if you don't wish to secure your pipeline templates by using a separate repository. This will default to `true`. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `azure_devops_use_organisation_legacy_url` | `TF_VAR` | `false` | If you have not migrated to the modern url (still using `https://.visualstudio.com`) for your Azure DevOps organisation, then set this to `true`. | + | `azure_devops_create_project` | `TF_VAR` | `true` | If you have an existing project you want to use rather than creating a new one, select `true`. We recommend creating a new project to ensure it is isolated by a strong security boundary. | + | `azure_devops_project_name` | `TF_VAR` | `` | Replace `` with the name of the Azure DevOps project to create or the name of an existing project if you set `azure_devops_create_project` to `false`. | + | `use_self_hosted_agents` | `TF_VAR` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. | + | `use_private_networking` | `TF_VAR` | `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` | `TF_VAR` | `false` | This is not relecant to Bicep and we'll remove the need to specify it later, leave it set to `false`. | + | `apply_approvers` | `TF_VAR` | `` | 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` | `TF_VAR` | `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. - [Bicep Complete Starter Module][wiki_starter_module_bicep_complete] @@ -73,7 +75,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. @@ -90,13 +92,13 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```pwsh # Windows New-Item -ItemType "file" c:\accelerator\config\inputs.yaml -Force - New-Item -ItemType "directory" c:\accelerator\output + New-Item -ItemType "directory" c:\accelerator\output ``` ```pwsh # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output ``` ```plaintext @@ -113,34 +115,35 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, 1. Complete - [inputs-azure-devops-terraform-complete.yaml][example_powershell_inputs_azure_devops_terraform_complete] 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | - | `bootstrap` | `alz_azuredevops` | This is the choice of Version Control System. Keep this as `alz_azuredevops` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete`, `hubnetworking` or `basic` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_locations` | `[,]` | This field is only required for multi-region starter modules and should be supplied in place of `starter_location`. Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `azure_devops_personal_access_token` | `` | Replace `` with the `token-1` Azure DevOps PAT you generated in a previous step. | - | `azure_devops_agents_personal_access_token` | `` | Replace `` with the `token-2` Azure DevOps PAT you generated in the previous step specifically for the self-hosted agents. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted agents. | - | `azure_devops_organization_name` | `` | Replace `` with the name of your Azure DevOps organization. This is the section of the url after `dev.azure.com` or before `.visualstudio.com`. E.g. enter `my-org` for `https://dev.azure.com/my-org`. | - | `use_separate_repository_for_templates` | `true` | Determine whether to create a separate repository to store pipeline templates as an extra layer of security. Set to `false` if you don't wish to secure your pipeline templates by using a separate repository. This will default to `true`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | - | `azure_devops_use_organisation_legacy_url` | `false` | If you have not migrated to the modern url (still using `https://.visualstudio.com`) for your Azure DevOps organisation, then set this to `true`. | - | `azure_devops_create_project` | `true` | If you have an existing project you want to use rather than creating a new one, select `true`. We recommend creating a new project to ensure it is isolated by a strong security boundary. | - | `azure_devops_project_name` | `` | Replace `` with the name of the Azure DevOps project to create or the name of an existing project if you set `azure_devops_create_project` to `false`. | - | `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` | `` | 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`. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "terraform"` or `env:TF_VAR_azure_devops_personal_access_token = "*****..."`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_azuredevops` | This is the choice of Version Control System. Keep this as `alz_azuredevops` for this example. | + | `starter_module_name` | `ALZ` | `complete_multi_region` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete_multi_region`, `complete`, `hubnetworking` or `basic` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `azure_devops_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-1` Azure DevOps PAT you generated in a previous step. | + | `azure_devops_agents_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-2` Azure DevOps PAT you generated in the previous step specifically for the self-hosted agents. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted agents. | + | `azure_devops_organization_name` | `TF_VAR` | `` | Replace `` with the name of your Azure DevOps organization. This is the section of the url after `dev.azure.com` or before `.visualstudio.com`. E.g. enter `my-org` for `https://dev.azure.com/my-org`. | + | `use_separate_repository_for_templates` | `TF_VAR` | `true` | Determine whether to create a separate repository to store pipeline templates as an extra layer of security. Set to `false` if you don't wish to secure your pipeline templates by using a separate repository. This will default to `true`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `azure_devops_use_organisation_legacy_url` | `TF_VAR` | `false` | If you have not migrated to the modern url (still using `https://.visualstudio.com`) for your Azure DevOps organisation, then set this to `true`. | + | `azure_devops_create_project` | `TF_VAR` | `true` | If you have an existing project you want to use rather than creating a new one, select `true`. We recommend creating a new project to ensure it is isolated by a strong security boundary. | + | `azure_devops_project_name` | `TF_VAR` | `` | Replace `` with the name of the Azure DevOps project to create or the name of an existing project if you set `azure_devops_create_project` to `false`. | + | `use_self_hosted_agents` | `TF_VAR` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. | + | `use_private_networking` | `TF_VAR` | `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` | `TF_VAR` | `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` | `TF_VAR` | `` | 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` | `TF_VAR` | `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. - [Terraform Basic Starter Module][wiki_starter_module_terraform_basic]: Management groups and policies. @@ -155,7 +158,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. diff --git a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-GitHub.md b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-GitHub.md index c24a510d..ee8e8df5 100644 --- a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-GitHub.md +++ b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-GitHub.md @@ -14,11 +14,11 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```pwsh # Windows New-Item -ItemType "file" c:\accelerator\config\inputs.yaml -Force - New-Item -ItemType "directory" c:\accelerator\output + New-Item -ItemType "directory" c:\accelerator\output # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output ``` ```plaintext @@ -31,30 +31,32 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, 1. Open your `inputs.yaml` file in Visual Studio Code (or your preferred editor) and copy the content from [inputs-github-bicep-complete.yaml][example_powershell_inputs_github_bicep_complete] into that file. 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | - | `bootstrap` | `alz_github` | This is the choice of Version Control System. Keep this as `alz_github` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `github_personal_access_token` | `` | Replace `` with the `token-1` GitHub PAT you generated in a previous step. | - | `github_runners_personal_access_token` | `` | Replace `` with the `token-2` GitHub PAT you generated in the previous step specifically for the self-hosted runners. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted runners. | - | `github_organization_name` | `` | Replace `` with the name of your GitHub organization. This is the section of the url after `github.com`. E.g. enter `my-org` for `https://github.com/my-org`. | - | `use_separate_repository_for_templates` | `true` | Determine whether to create a separate repository to store workflow templates as an extra layer of security. Set to `false` if you don't wish to secure your workflow templates by using a separate repository. This will default to `true`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and GitHub resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | - | `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` | `` | 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`. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "bicep"` or `env:TF_VAR_github_personal_access_token = "*****..."`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_github` | This is the choice of Version Control System. Keep this as `alz_github` for this example. | + | `starter_module_name` | `ALZ` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `github_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-1` GitHub PAT you generated in a previous step. | + | `github_runners_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-2` GitHub PAT you generated in the previous step specifically for the self-hosted runners. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted runners. | + | `github_organization_name` | `TF_VAR` | `` | Replace `` with the name of your GitHub organization. This is the section of the url after `github.com`. E.g. enter `my-org` for `https://github.com/my-org`. | + | `use_separate_repository_for_templates` | `TF_VAR` | `true` | Determine whether to create a separate repository to store workflow templates as an extra layer of security. Set to `false` if you don't wish to secure your workflow templates by using a separate repository. This will default to `true`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and GitHub resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `use_self_hosted_agents` | `TF_VAR` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. | + | `use_private_networking` | `TF_VAR` | `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` | `TF_VAR` | `false` | This is not relevant to Bicep and we'll remove the need to specify it later, leave it set to `false`. | + | `apply_approvers` | `TF_VAR` | `` | 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` | `TF_VAR` | `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. - [Bicep Complete Starter Module][wiki_starter_module_bicep_complete] @@ -65,7 +67,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output" # 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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. @@ -82,11 +84,11 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```pwsh # Windows New-Item -ItemType "file" c:\accelerator\config\inputs.yaml -Force - New-Item -ItemType "directory" c:\accelerator\output + New-Item -ItemType "directory" c:\accelerator\output # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output ``` ```plaintext @@ -103,31 +105,32 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, 1. Complete - [inputs-github-terraform-complete.yaml][example_powershell_inputs_github_terraform_complete] 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | - | `bootstrap` | `alz_github` | This is the choice of Version Control System. Keep this as `alz_github` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete`, `hubnetworking` or `basic` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_locations` | `[,]` | This field is only required for multi-region starter modules and should be supplied in place of `starter_location`. Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `github_personal_access_token` | `` | Replace `` with the `token-1` GitHub PAT you generated in a previous step. | - | `github_runners_personal_access_token` | `` | Replace `` with the `token-2` GitHub PAT you generated in the previous step specifically for the self-hosted runners. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted runners. | - | `github_organization_name` | `` | Replace `` with the name of your GitHub organization. This is the section of the url after `github.com`. E.g. enter `my-org` for `https://github.com/my-org`. | - | `use_separate_repository_for_templates` | `true` | Determine whether to create a separate repository to store workflow templates as an extra layer of security. Set to `false` if you don't wish to secure your workflow templates by using a separate repository. This will default to `true`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and GitHub resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | - | `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` | `` | 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`. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "terraform"` or `env:TF_VAR_github_personal_access_token = "*****..."`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_github` | This is the choice of Version Control System. Keep this as `alz_github` for this example. | + | `starter_module_name` | `ALZ` | `complete_multi_region` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete_multi_region`, `complete`, `hubnetworking` or `basic` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `github_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-1` GitHub PAT you generated in a previous step. | + | `github_runners_personal_access_token` | `TF_VAR` | `` | Replace `` with the `token-2` GitHub PAT you generated in the previous step specifically for the self-hosted runners. This only applies if you have `use_self_hosted_agents` set to `true`. You can set this to an empty string `""` if you are not using self-hosted runners. | + | `github_organization_name` | `TF_VAR` | `` | Replace `` with the name of your GitHub organization. This is the section of the url after `github.com`. E.g. enter `my-org` for `https://github.com/my-org`. | + | `use_separate_repository_for_templates` | `TF_VAR` | `true` | Determine whether to create a separate repository to store workflow templates as an extra layer of security. Set to `false` if you don't wish to secure your workflow templates by using a separate repository. This will default to `true`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and GitHub resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and GitHub resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `use_self_hosted_agents` | `TF_VAR` | `true` | This controls if you want to deploy self-hosted agents. This will default to `true`. | + | `use_private_networking` | `TF_VAR` | `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` | `TF_VAR` | `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` | `TF_VAR` | `` | 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` | `TF_VAR` | `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. - [Terraform Basic Starter Module][wiki_starter_module_terraform_basic]: Management groups and policies. @@ -140,7 +143,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output" # 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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. diff --git a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Local.md b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Local.md index 5ecf895f..0e55d7fb 100644 --- a/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Local.md +++ b/docs/wiki/[User-Guide]-Quick-Start-Phase-2-Local.md @@ -14,40 +14,46 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```pwsh # Windows New-Item -ItemType "file" c:\accelerator\config\inputs.yaml -Force - New-Item -ItemType "directory" c:\accelerator\output + New-Item -ItemType "directory" c:\accelerator\output + New-Item -ItemType "directory" c:\accelerator\target # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output + New-Item -ItemType "directory" /accelerator/target ``` ```plaintext 📂accelerator ┣ 📂config ┃ ┗ 📜inputs.yaml - ┗ 📂output + ┃ 📂output + ┗ 📂target ``` 1. Open your `inputs.yaml` file in Visual Studio Code (or your preferred editor) and copy the content from [inputs-local-bicep-complete.yaml][example_powershell_inputs_local_bicep_complete] into that file. 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | - | `bootstrap` | `alz_local` | This is the choice of Version Control System. Keep this as `alz_local` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `target_directory` | `` | This is the directory where the ALZ module code will be created. This defaults a directory called `local` in the root of the accelerator directory if not supplied. | - | `create_bootstrap_resources_in_azure` | `true` | This determines whether the bootstrap will create the bootstrap resources in Azure. This defaults to `true`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "bicep"` or `env:TF_VAR_target_directory = "./accelerator/target"`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `bicep` | This is the choice of `bicep` or `terraform`. Keep this as `bicep` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_local` | This is the choice of Version Control System. Keep this as `alz_local` for this example. | + | `starter_module_name` | `ALZ` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Keep this as `complete` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `target_directory` | `TF_VAR` | `/accelerator/target` | This is the directory where the ALZ module code will be created. This defaults a directory called `local-output` in the root of the accelerator output directory if not supplied. | + | `create_bootstrap_resources_in_azure` | `TF_VAR` | `true` | This determines whether the bootstrap will create the bootstrap resources in Azure. This defaults to `true`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `grant_permissions_to_current_user` | `TF_VAR` | `true` | This determines whether the bootstrap will grant the current user permissions to the management group structure created by the accelerator. This defaults to `true` so that the starter module can be immediately deployed from the local file system. Set this to `false` if you itend to wire up CI/CD with your own provider. | 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. - [Bicep Complete Starter Module][wiki_starter_module_bicep_complete] @@ -58,7 +64,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, Deploy-Accelerator -inputs "c:\accelerator\config\inputs.yaml" -output "c:\accelerator\output" # 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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. @@ -76,19 +82,20 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, # Windows New-Item -ItemType "file" c:\accelerator\config\inputs.yaml -Force New-Item -ItemType "directory" c:\accelerator\output - ``` + New-Item -ItemType "directory" c:\accelerator\target - ```pwsh # Linux/Mac - New-Item -ItemType "file" ~/accelerator/config/inputs.yaml -Force - New-Item -ItemType "directory" ~/accelerator/output + New-Item -ItemType "file" /accelerator/config/inputs.yaml -Force + New-Item -ItemType "directory" /accelerator/output + New-Item -ItemType "directory" /accelerator/target ``` ```plaintext 📂accelerator ┣ 📂config ┃ ┗ 📜inputs.yaml - ┗ 📂output + ┃ 📂output + ┗ 📂target ``` 1. Open your `inputs.yaml` file in Visual Studio Code (or your preferred editor) and copy the content from the relevant input file for your chosen starter module: @@ -98,24 +105,26 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, 1. Complete - [inputs-local-terraform-complete.yaml][example_powershell_inputs_local_terraform_complete] 1. Check through the file and update each input as required. It is mandatory to update items with placeholders surrounded by angle brackets `<>`: - | Input | Placeholder | Description | - | - | -- | --- | - | `iac` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | - | `bootstrap` | `alz_local` | This is the choice of Version Control System. Keep this as `alz_local` for this example. | - | `starter` | `complete` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete`, `hubnetworking` or `basic` for this example. This also determines the second set of inputs you'll be prompted for. | - | `bootstrap_location` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_location` | `` | Replace `` with the Azure region where you would like to deploy the starter module resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | - | `starter_locations` | `[,]` | This field is only required for multi-region starter modules and should be supplied in place of `starter_location`. Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | - | `root_parent_management_group_id` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | - | `subscription_id_management` | `` | Replace `` with the id of the management subscription you created in the previous phase. | - | `subscription_id_identity` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | - | `subscription_id_connectivity` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | - | `target_directory` | `` | This is the directory where the ALZ module code will be created. This defaults a directory called `local` in the root of the accelerator directory if not supplied. | - | `create_bootstrap_resources_in_azure` | `true` | This determines whether the bootstrap will create the bootstrap resources in Azure. This defaults to `true`. | - | `bootstrap_subscription_id` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | - | `service_name` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | - | `environment_name` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | - | `postfix_number` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + >NOTE: The following inputs can also be supplied via environment variables. This may be useful for sensitive values you don't wish to persist to a file. The `Env Var Prefix` denotes the prefix the environment variable should have. The environment variable is formatting is `_`, e.g. `env:ALZ_iac_type = "terraform"` or `env:TF_VAR_target_directory = "./accelerator/target"`. + + | Input | Env Var Prefix | Placeholder | Description | + | - | - | -- | --- | + | `iac_type` | `ALZ` | `terraform` | This is the choice of `bicep` or `terraform`. Keep this as `terraform` for this example. | + | `bootstrap_module_name` | `ALZ` | `alz_local` | This is the choice of Version Control System. Keep this as `alz_local` for this example. | + | `starter_module_name` | `ALZ` | `complete_multi_region` | This is the choice of [Starter Modules][wiki_starter_modules], which is the baseline configuration you want for your Azure landing zone. Choose `complete_multi_region`, `complete`, `hubnetworking` or `basic` for this example. | + | `bootstrap_location` | `TF_VAR` | `` | Replace `` with the Azure region where you would like to deploy the bootstrap resources in Azure. This field expects the `name` of the region, such as `uksouth`. You can find a full list of names by running `az account list-locations -o table`. | + | `starter_locations` | `TF_VAR` | `[,]` | Replace `` and `` with the Azure regions where you would like to deploy the starter module resources in Azure. This field expects the `name` of the regions in and array, such as `["uksouth", "ukwest"]`. You can find a full list of names by running `az account list-locations -o table`. | + | `root_parent_management_group_id` | `TF_VAR` | `""` | This is the id of the management group that will be the parent of the management group structure created by the accelerator. If you are using the `Tenant Root Group` management group, you leave this as an empty string `""` or supply the tenant id. | + | `subscription_id_management` | `TF_VAR` | `` | Replace `` with the id of the management subscription you created in the previous phase. | + | `subscription_id_identity` | `TF_VAR` | `` | Replace `` with the id of the identity subscription you created in the previous phase. | + | `subscription_id_connectivity` | `TF_VAR` | `` | Replace `` with the id of the connectivity subscription you created in the previous phase. | + | `target_directory` | `TF_VAR` | `/accelerator/target` | This is the directory where the ALZ module code will be created. This defaults a directory called `local-output` in the root of the accelerator output directory if not supplied. | + | `create_bootstrap_resources_in_azure` | `TF_VAR` | `true` | This determines whether the bootstrap will create the bootstrap resources in Azure. This defaults to `true`. | + | `bootstrap_subscription_id` | `TF_VAR` | `""` | Enter the id of the subscription in which you would like to deploy the bootstrap resources in Azure. If left blank, the subscription you are connected to via `az login` will be used. In most cases this is the management subscription, but you can specifiy a separate subscription if you prefer. | + | `service_name` | `TF_VAR` | `alz` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg--mgmt-uksouth-001`. We recommend using `alz` for this. | + | `environment_name` | `TF_VAR` | `mgmt` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz--uksouth-001`. We recommend using `mgmt` for this. | + | `postfix_number` | `TF_VAR` | `1` | This is used to build up the names of your Azure and Azure DevOps resources, for example `rg-alz-mgmt-uksouth-`. We recommend using `1` for this. | + | `grant_permissions_to_current_user` | `TF_VAR` | `true` | This determines whether the bootstrap will grant the current user permissions to the management group structure and stroage account created by the accelerator. This defaults to `true` so that the starter module can be immediately deployed from the local file system. Set this to `false` if you itend to wire up CI/CD with your own provider. | 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. - [Terraform Basic Starter Module][wiki_starter_module_terraform_basic]: Management groups and policies. @@ -130,7 +139,7 @@ Although you can just run `Deploy-Accelerator` and fill out the prompted inputs, ```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" -output "/accelerator/output" ``` 1. You will see a Terraform `init` and `apply` happen. diff --git a/docs/wiki/[User-Guide]-Quick-Start-Phase-3.md b/docs/wiki/[User-Guide]-Quick-Start-Phase-3.md index 205c2705..1137ccdf 100644 --- a/docs/wiki/[User-Guide]-Quick-Start-Phase-3.md +++ b/docs/wiki/[User-Guide]-Quick-Start-Phase-3.md @@ -33,6 +33,22 @@ Now you have created your bootstrapped environment you can deploy you Azure land ### 3.1.3 Local file system +Follow the steps below to deploy the landing zone locally. If you want to hook it up to you custom version control system, follow their documentation on how to that. + +#### 3.1.3.1 Bicep + +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. +1. Login to Azure using `Connect-AzAccount -TenantId 00000000-0000-0000-0000-000000000000 -SubscriptionId 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 what if 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. + +#### 3.1.3.2 Terraform + 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. diff --git a/docs/wiki/[User-Guide]-Starter-Module-Bicep-Complete.md b/docs/wiki/[User-Guide]-Starter-Module-Bicep-Complete.md index caf89e85..481a533b 100644 --- a/docs/wiki/[User-Guide]-Starter-Module-Bicep-Complete.md +++ b/docs/wiki/[User-Guide]-Starter-Module-Bicep-Complete.md @@ -12,7 +12,7 @@ The following table describes the inputs required for the `complete` starter mod | Input | Placeholder | Description | | - | -- | --- | | `Prefix` | `landing-zone` | This is the defaut prefix for names of resources and management groups. | -| `SecondaryLocation` | `westus2` | The secondary location for the landing zone. Only used if the `networkType` has a multi-region configuration specified. | +| `SecondaryLocation` | `westus2` | The secondary location for the landing zone. Only used if the `networkType` has a multi-region configuration specified. | | `Environment` | `live` | The environment name for the landing zone. This can be any lower case string. (e.g. `live` or `canary`) | | `networkType` | `hubNetworking` | The type of network configuration to deploy. Currently only `hubNetworking`, `hubNetworkingMultiRegion`, `vwanConnectivity,` `vwanConnectivityMultiRegion` or `none` are supported. | | `SecurityContact` | `` | The email address of the security contact for the landing zone. | diff --git a/docs/wiki/_Sidebar.md b/docs/wiki/_Sidebar.md index f00fc539..9a5448d8 100644 --- a/docs/wiki/_Sidebar.md +++ b/docs/wiki/_Sidebar.md @@ -19,12 +19,12 @@ - [Terraform - Basic][wiki_starter_module_terraform_basic] - [Terraform - Hub Networking][wiki_starter_module_terraform_hubnetworking] - [Terraform - Complete][wiki_starter_module_terraform_complete] - - [Terraform - Complete Multi Region][wiki_starter_module_terraform_complete_multi_region] - [Configuration YAML Schema][wiki_yaml_schema_reference] - - [Example Multi Region Hub and Spoke config][example_starter_module_complete_config_hub_spoke_multi_region] - - [Example Multi Region Virtual WAN config][example_starter_module_complete_config_vwan_multi_region] - [Example Hub and Spoke config][example_starter_module_complete_config_hub_spoke] - [Example Virtual WAN config][example_starter_module_complete_config_vwan] + - [Terraform - Complete Multi Region][wiki_starter_module_terraform_complete_multi_region] + - [Example Multi Region Hub and Spoke config][example_starter_module_complete_config_hub_spoke_multi_region] + - [Example Multi Region Virtual WAN config][example_starter_module_complete_config_vwan_multi_region] - Input Files - [Azure DevOps Bicep Complete][example_powershell_inputs_azure_devops_bicep_complete] - [Azure DevOps Terraform Basic][example_powershell_inputs_azure_devops_terraform_basic] diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml index e761f8f1..1e88b175 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-bicep-complete.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "bicep" -bootstrap: "alz_azuredevops" -starter: "complete" +iac_type: "bicep" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,24 +19,28 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Bicep-Complete) Prefix: "alz" -SecondaryLocation: "" Environment: "live" networkType: "hubNetworking" SecurityContact: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-basic.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-basic.yaml index 4443be90..513dc3d2 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-basic.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-basic.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2212-azure-devops-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_azuredevops" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,21 +19,26 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Basic Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Basic) root_id: "" root_name: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-multi-region.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-multi-region.yaml index 9b4b2d0c..607ae556 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-multi-region.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-multi-region.yaml @@ -3,9 +3,9 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2212-azure-devops-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_azuredevops" -starter: "complete_multi_region" +iac_type: "terraform" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete_multi_region" # Shared Interface Inputs bootstrap_location: "" @@ -19,21 +19,26 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-Multi-Region) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-vnext.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-vnext.yaml index 143e30cc..0d33a4b7 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-vnext.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete-vnext.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2212-azure-devops-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_azuredevops" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,21 +19,26 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete vNext Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-vNext) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml index 08daa94c..77794731 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-complete.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2212-azure-devops-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_azuredevops" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,21 +19,26 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-hubnetworking.yaml b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-hubnetworking.yaml index 23dbba90..332ba2ce 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-hubnetworking.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-azure-devops-terraform-hubnetworking.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2212-azure-devops-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_azuredevops" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_azuredevops" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,19 +19,19 @@ subscription_id_connectivity: "" azure_devops_personal_access_token: "" azure_devops_agents_personal_access_token: "" azure_devops_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -azure_devops_use_organisation_legacy_url: "false" -azure_devops_create_project: "true" +postfix_number: 1 +azure_devops_use_organisation_legacy_url: false +azure_devops_create_project: true azure_devops_project_name: "" -use_self_hosted_agents: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +use_self_hosted_agents: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Hub Networking Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-HubNetworking) @@ -41,3 +41,8 @@ hub_virtual_network_address_prefix: "" firewall_subnet_address_prefix: "" gateway_subnet_address_prefix: "" virtual_network_gateway_creation_enabled: "true" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml index 4caf7db9..68890ce1 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-bicep-complete.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2221-github-with-bicep # Basic Inputs -iac: "bicep" -bootstrap: "alz_github" -starter: "complete" +iac_type: "bicep" +bootstrap_module_name: "alz_github" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,21 +19,25 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Bicep-Complete) Prefix: "alz" -SecondaryLocation: "" Environment: "live" networkType: "hubNetworking" SecurityContact: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-basic.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-basic.yaml index d5f7c8e0..f7240337 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-basic.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-basic.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2222-github-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_github" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_github" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,18 +19,23 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Basic Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Basic) root_id: "" root_name: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-multi-region.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-multi-region.yaml index 9271abd6..a1878430 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-multi-region.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-multi-region.yaml @@ -3,9 +3,9 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2222-github-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_github" -starter: "complete_multi_region" +iac_type: "terraform" +bootstrap_module_name: "alz_github" +starter_module_name: "complete_multi_region" # Shared Interface Inputs bootstrap_location: "" @@ -19,18 +19,23 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-Multi-Region) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-vnext.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-vnext.yaml index d67ed3d5..74cd0fac 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-vnext.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete-vnext.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2222-github-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_github" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_github" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,18 +19,23 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete vNext Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-vNext) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml index 8cdeb3c8..7c2cac08 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-complete.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2222-github-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_github" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_github" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,18 +19,23 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-hubnetworking.yaml b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-hubnetworking.yaml index 4eea7201..0a521add 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-github-terraform-hubnetworking.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-github-terraform-hubnetworking.yaml @@ -3,13 +3,13 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-GitHub#2222-github-with-terraform # Basic Inputs -iac: "terraform" -bootstrap: "alz_github" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_github" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" @@ -19,16 +19,16 @@ subscription_id_connectivity: "" github_personal_access_token: "" github_runners_personal_access_token: "" github_organization_name: "" -use_separate_repository_for_templates: "true" +use_separate_repository_for_templates: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" -use_self_hosted_runners: "true" -use_private_networking: "true" -allow_storage_access_from_my_ip: "false" +postfix_number: 1 +use_self_hosted_runners: true +use_private_networking: true +allow_storage_access_from_my_ip: false apply_approvers: [""] -create_branch_policies: "true" +create_branch_policies: true # Hub Networking Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-HubNetworking) @@ -38,3 +38,8 @@ hub_virtual_network_address_prefix: "" firewall_subnet_address_prefix: "" gateway_subnet_address_prefix: "" virtual_network_gateway_creation_enabled: "true" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml index 54b9164c..f7683024 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-bicep-complete.yaml @@ -3,30 +3,34 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "bicep" -bootstrap: "alz_local" -starter: "complete" +iac_type: "bicep" +bootstrap_module_name: "alz_local" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" +target_directory: "/accelerator/target" create_bootstrap_resources_in_azure: "true" bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 # Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Bicep-Complete) Prefix: "alz" -SecondaryLocation: "" Environment: "live" networkType: "hubNetworking" SecurityContact: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-basic.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-basic.yaml index fec83103..6a0c6a5d 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-basic.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-basic.yaml @@ -3,27 +3,33 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "terraform" -bootstrap: "alz_local" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_local" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" -create_bootstrap_resources_in_azure: "true" +target_directory: "/accelerator/target" +create_bootstrap_resources_in_azure: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 +grant_permissions_to_current_user: true # Basic Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Basic) root_id: "" root_name: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-multi-region.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-multi-region.yaml index 97464fd4..ed5ee3a1 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-multi-region.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-multi-region.yaml @@ -3,9 +3,9 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "terraform" -bootstrap: "alz_local" -starter: "complete_multi_region" +iac_type: "terraform" +bootstrap_module_name: "alz_local" +starter_module_name: "complete_multi_region" # Shared Interface Inputs bootstrap_location: "" @@ -16,14 +16,20 @@ subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" -create_bootstrap_resources_in_azure: "true" +target_directory: "/accelerator/target" +create_bootstrap_resources_in_azure: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 +grant_permissions_to_current_user: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-Multi-Region) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-vnext.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-vnext.yaml index 875324cb..b2fb8ef8 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-vnext.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete-vnext.yaml @@ -3,27 +3,33 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "terraform" -bootstrap: "alz_local" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_local" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" -create_bootstrap_resources_in_azure: "true" +target_directory: "/accelerator/target" +create_bootstrap_resources_in_azure: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 +grant_permissions_to_current_user: true # Complete vNext Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete-vNext) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml index fb3f5af3..08b002a2 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-complete.yaml @@ -3,27 +3,33 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "terraform" -bootstrap: "alz_local" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_local" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" -create_bootstrap_resources_in_azure: "true" +target_directory: "/accelerator/target" +create_bootstrap_resources_in_azure: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 +grant_permissions_to_current_user: true # Complete Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-Complete) configuration_file_path: "" # Only required for the `complete` starter module. NOTE: This must be an absolute path. default_postfix: "" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-hubnetworking.yaml b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-hubnetworking.yaml index 5a285fb9..8c0b2f97 100644 --- a/docs/wiki/examples/powershell-inputs/inputs-local-terraform-hubnetworking.yaml +++ b/docs/wiki/examples/powershell-inputs/inputs-local-terraform-hubnetworking.yaml @@ -3,25 +3,26 @@ # https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start-Phase-2-Azure-DevOps#2211-azure-devops-with-bicep # Basic Inputs -iac: "terraform" -bootstrap: "alz_local" -starter: "complete" +iac_type: "terraform" +bootstrap_module_name: "alz_local" +starter_module_name: "complete" # Shared Interface Inputs bootstrap_location: "" -starter_location: "" +starter_locations: [""] root_parent_management_group_id: "" subscription_id_management: "" subscription_id_identity: "" subscription_id_connectivity: "" # Bootstrap Inputs -target_directory: "" -create_bootstrap_resources_in_azure: "true" +target_directory: "/accelerator/target" +create_bootstrap_resources_in_azure: true bootstrap_subscription_id: "" service_name: "alz" environment_name: "mgmt" -postfix_number: "1" +postfix_number: 1 +grant_permissions_to_current_user: true # Hub Networking Starter Module Specific Variables # (Details: https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Starter-Module-Terraform-HubNetworking) @@ -31,3 +32,8 @@ hub_virtual_network_address_prefix: "" firewall_subnet_address_prefix: "" gateway_subnet_address_prefix: "" virtual_network_gateway_creation_enabled: "true" + +# Advanced Inputs +bootstrap_module_version: "latest" +starter_module_version: "latest" +#output_folder_path: "/accelerator/output" diff --git a/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 new file mode 100644 index 00000000..2980f54f --- /dev/null +++ b/src/ALZ/Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1 @@ -0,0 +1,72 @@ +function Convert-BicepConfigToInputConfig { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $false)] + [PSCustomObject]$bicepConfig, + + [Parameter(Mandatory = $false)] + [PSCustomObject]$validators, + + [Parameter(Mandatory = $false)] + [PSCustomObject]$appendToObject = $null + ) + + if ($PSCmdlet.ShouldProcess("Parse Interface Variables into Config", "modify")) { + + $configItems = [PSCustomObject]@{} + if($appendToObject -ne $null) { + $configItems = $appendToObject + } + + Write-Verbose $validators + + foreach($variable in $bicepConfig.inputs.PSObject.Properties) { + Write-Verbose "Parsing variable $($variable.Name)" + $description = $variable.Value.description + + $configItem = [PSCustomObject]@{} + $configItem | Add-Member -NotePropertyName "Source" -NotePropertyValue $variable.Value.source + $configItem | Add-Member -NotePropertyName "Value" -NotePropertyValue "" + + if($variable.Value.PSObject.Properties.Name -contains "sourceInput") { + $configItem | Add-Member -NotePropertyName "SourceInput" -NotePropertyValue $variable.Value.sourceInput + } + + if($variable.Value.PSObject.Properties.Name -contains "pattern") { + $configItem | Add-Member -NotePropertyName "Pattern" -NotePropertyValue $variable.Value.pattern + } + + if($variable.Value.PSObject.Properties.Name -contains "process") { + $configItem | Add-Member -NotePropertyName "Process" -NotePropertyValue $variable.Value.process + } + + if($variable.Value.PSObject.Properties.Name -contains "default") { + $defaultValue = $variable.Value.default + $configItem | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue + } + + if($variable.Value.PSObject.Properties.Name -contains "validation") { + $validationType = $variable.Value.validation + $validator = $validators.PSObject.Properties[$validationType].Value + $description = "$description ($($validator.Description))" + Write-Verbose "Adding $($variable.Value.validation) validation for $($variable.Name). Validation type: $($validator.Type)" + if($validator.Type -eq "AllowedValues"){ + $configItem | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues + } + if($validator.Type -eq "Valid"){ + $configItem | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid + } + $configItem | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType + } + + if($variable.Value.PSObject.Properties.Name -contains "targets") { + $configItem | Add-Member -NotePropertyName "targets" -NotePropertyValue $variable.Value.targets + } + + $configItem | Add-Member -NotePropertyName "Description" -NotePropertyValue $description + $configItems | Add-Member -NotePropertyName $variable.Name -NotePropertyValue $configItem + } + } + + return $configItems +} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 new file mode 100644 index 00000000..f3e3be6b --- /dev/null +++ b/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToInputConfig.ps1 @@ -0,0 +1,76 @@ +function Convert-HCLVariablesToInputConfig { + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $false)] + [string] $targetVariableFile, + + [Parameter(Mandatory = $false)] + [string] $hclParserToolPath, + + [Parameter(Mandatory = $false)] + [PSCustomObject]$validators, + + [Parameter(Mandatory = $false)] + [PSCustomObject]$appendToObject = $null + ) + + if ($PSCmdlet.ShouldProcess("Parse HCL Variables into Config", "modify")) { + $terraformVariables = & $hclParserToolPath $targetVariableFile | ConvertFrom-Json + + if($terraformVariables.PSObject.Properties.Name -notcontains "variable") { + Write-Verbose "No variables found in $targetVariableFile, skipping..." + return + } + + $configItems = [PSCustomObject]@{} + if($appendToObject -ne $null) { + $configItems = $appendToObject + } + + foreach($variable in $terraformVariables.variable.PSObject.Properties) { + if($variable.Value[0].PSObject.Properties.Name -contains "description") { + $description = $variable.Value[0].description + $validationTypeSplit = $description -split "\|" + + $hasValidation = $false + + if($validationTypeSplit.Length -gt 1) { + $description = $validationTypeSplit[0].Trim() + } + + if($validationTypeSplit.Length -eq 2) { + $splitItem = $validationTypeSplit[1].Trim() + $validationType = $splitItem + $hasValidation = $true + } + } + + $configItem = [PSCustomObject]@{} + $configItem | Add-Member -NotePropertyName "Value" -NotePropertyValue "" + $configItem | Add-Member -NotePropertyName "Source" -NotePropertyValue "input" + + if($variable.Value[0].PSObject.Properties.Name -contains "default") { + $configItem | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $variable.Value[0].default + } + + if($hasValidation) { + Write-Verbose "Validation: $hasValidation - $validationType" + $validator = $validators.PSObject.Properties[$validationType].Value + $description = "$description ($($validator.Description))" + if($validator.Type -eq "AllowedValues"){ + $configItem | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues + } + if($validator.Type -eq "Valid"){ + $configItem | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid + } + $configItem | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType + } + + $configItem | Add-Member -NotePropertyName "Description" -NotePropertyValue $description + + $configItems | Add-Member -NotePropertyName $variable.Name -NotePropertyValue $configItem + } + } + + return $configItems +} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1 deleted file mode 100644 index 8a3c5269..00000000 --- a/src/ALZ/Private/Config-Helpers/Convert-HCLVariablesToUserInputConfig.ps1 +++ /dev/null @@ -1,114 +0,0 @@ -function Convert-HCLVariablesToUserInputConfig { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string] $targetVariableFile, - - [Parameter(Mandatory = $false)] - [string] $hclParserToolPath, - - [Parameter(Mandatory = $false)] - [PSCustomObject]$validators, - - [Parameter(Mandatory = $false)] - [PSCustomObject]$appendToObject = $null, - - [Parameter(Mandatory = $false)] - [switch]$allComputedInputs - ) - - if ($PSCmdlet.ShouldProcess("Parse HCL Variables into Config", "modify")) { - $terraformVariables = & $hclParserToolPath $targetVariableFile | ConvertFrom-Json - - $starterModuleConfiguration = [PSCustomObject]@{} - if($appendToObject -ne $null) { - $starterModuleConfiguration = $appendToObject - } - - foreach($variable in $terraformVariables.variable.PSObject.Properties) { - $description = $variable.Value[0].description - $validationTypeSplit = $description -split "\|" - - $hasValidation = $false - $order = 0 - - if($validationTypeSplit.Length -gt 1) { - $description = $validationTypeSplit[0].Trim() - } - - if($validationTypeSplit.Length -eq 2) { - $splitItem = $validationTypeSplit[1].Trim() - if($splitItem -match "^\d+$") { - $order = [convert]::ToInt32($splitItem) - } else { - $validationType = $splitItem - $hasValidation = $true - } - } - - if($validationTypeSplit.Length -eq 3) { - $order = [convert]::ToInt32($validationTypeSplit[1].Trim()) - $validationType = $validationTypeSplit[2].Trim() - $hasValidation = $true - } - - $inputType = "UserInput" - if($allComputedInputs) { - $inputType = "ComputedInput" - Write-Verbose "Name: $($variable.Name), Has Validation: $hasValidation, Order: $order, ValidationType: $validationType, Description: $description, InputType: $inputType" - } - - $sensitive = $false - if($variable.Value[0].PSObject.Properties.Name -contains "sensitive") { - $sensitive = $true - } - - $dataType = $variable.Value[0].type - $dataType = $dataType.Replace("`${", "").Replace("}", "") - - $starterModuleConfigurationInstance = [PSCustomObject]@{} - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Order" -NotePropertyValue $order - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Type" -NotePropertyValue $inputType - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Value" -NotePropertyValue "" - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "DataType" -NotePropertyValue $dataType - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Sensitive" -NotePropertyValue $sensitive - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Source" -NotePropertyValue "UserInterface" - - if($variable.Value[0].PSObject.Properties.Name -contains "default") { - $defaultValue = $variable.Value[0].default - - if($variable.Value[0].default.GetType().Name -eq "Boolean") { - $defaultValue = $variable.Value[0].default.ToString().ToLower() - } - if($dataType -eq "list(string)") { - $defaultValueRaw = $variable.Value[0].default - $defaultValue = "" - if($defaultValue.Length -gt 0) { - $join = $defaultValueRaw -join "`",`"" - $defaultValue = "`"$join`"" - } - } - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue - } - - if($hasValidation) { - Write-Verbose "Validation: $hasValidation - $validationType" - $validator = $validators.PSObject.Properties[$validationType].Value - $description = "$description ($($validator.Description))" - if($validator.Type -eq "AllowedValues"){ - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues - } - if($validator.Type -eq "Valid"){ - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid - } - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType - } - - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Description" -NotePropertyValue $description - - $starterModuleConfiguration | Add-Member -NotePropertyName $variable.Name -NotePropertyValue $starterModuleConfigurationInstance - } - } - - return $starterModuleConfiguration -} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Convert-InterfaceInputToUserInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-InterfaceInputToUserInputConfig.ps1 deleted file mode 100644 index b089c2a2..00000000 --- a/src/ALZ/Private/Config-Helpers/Convert-InterfaceInputToUserInputConfig.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -function Convert-InterfaceInputToUserInputConfig { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [PSCustomObject]$inputConfig, - - [Parameter(Mandatory = $false)] - [PSCustomObject]$validators, - - [Parameter(Mandatory = $false)] - [PSCustomObject]$appendToObject = $null - ) - - if ($PSCmdlet.ShouldProcess("Parse Interface Variables into Config", "modify")) { - - $starterModuleConfiguration = [PSCustomObject]@{} - if($appendToObject -ne $null) { - $starterModuleConfiguration = $appendToObject - } - - Write-Verbose $validators - - foreach($variable in $inputConfig.inputs.PSObject.Properties) { - Write-Verbose "Parsing variable $($variable.Name)" - $description = $variable.Value.description - - $order = 0 - if($variable.PSObject.Properties.Name -contains "display_order") { - $order = $variable.Value.display_order - } - - $inputType = $variable.Value.source -eq "input" ? "UserInput" : "ComputedInput" - $dataType = $variable.Value.type - - $sensitive = $false - if($variable.Value.PSObject.Properties.Name -contains "sensitive") { - $sensitive = $variable.Value.sensitive - } - - $starterModuleConfigurationInstance = [PSCustomObject]@{} - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Order" -NotePropertyValue $order - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Type" -NotePropertyValue $inputType - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "DataType" -NotePropertyValue $dataType - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Sensitive" -NotePropertyValue $sensitive - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Source" -NotePropertyValue "UserInterface" - - if($variable.Value.PSObject.Properties.Name -contains "Value") { - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Value" -NotePropertyValue $variable.Value.Value - } else { - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Value" -NotePropertyValue "" - } - - if($variable.Value.PSObject.Properties.Name -contains "default") { - $defaultValue = $variable.Value.default - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue - } - - if($variable.Value.PSObject.Properties.Name -contains "validation") { - $validationType = $variable.Value.validation - $validator = $validators.PSObject.Properties[$validationType].Value - $description = "$description ($($validator.Description))" - Write-Verbose "Adding $($variable.Value.validation) validation for $($variable.Name). Validation type: $($validator.Type)" - if($validator.Type -eq "AllowedValues"){ - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "AllowedValues" -NotePropertyValue $validator.AllowedValues - } - if($validator.Type -eq "Valid"){ - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Valid" -NotePropertyValue $validator.Valid - } - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Validator" -NotePropertyValue $validationType - } - - if($variable.Value.PSObject.Properties.Name -contains "Targets") { - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Targets" -NotePropertyValue $variable.Value.Targets - } - - $starterModuleConfigurationInstance | Add-Member -NotePropertyName "Description" -NotePropertyValue $description - $starterModuleConfiguration | Add-Member -NotePropertyName $variable.Name -NotePropertyValue $starterModuleConfigurationInstance - } - } - - return $starterModuleConfiguration -} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Convert-ParametersToInputConfig.ps1 b/src/ALZ/Private/Config-Helpers/Convert-ParametersToInputConfig.ps1 new file mode 100644 index 00000000..2edc45f5 --- /dev/null +++ b/src/ALZ/Private/Config-Helpers/Convert-ParametersToInputConfig.ps1 @@ -0,0 +1,42 @@ +function Convert-ParametersToInputConfig { + param( + [Parameter(Mandatory = $false)] + [PSCustomObject] $inputConfig, + [Parameter(Mandatory = $false)] + [hashtable] $parameters + ) + + foreach($parameterKey in $parameters.Keys) { + $parameter = $parameters[$parameterKey] + Write-Verbose "Processing parameter $parameterKey $(ConvertTo-Json $parameter -Depth 100)" + + foreach($parameterAlias in $parameter.aliases) { + if($inputConfig.PsObject.Properties.Name -contains $parameterAlias) { + Write-Verbose "Alias $parameterAlias exists in input config, renaming..." + $configItem = $inputConfig.PSObject.Properties | Where-Object { $_.Name -eq $parameterAlias } + $inputConfig | Add-Member -NotePropertyName $parameterKey -NotePropertyValue $configItem.Value + $inputConfig.PSObject.Properties.Remove($configItem.Name) + continue + } + } + + if($inputConfig.PsObject.Properties.Name -notcontains $parameterKey) { + $variableValue = [Environment]::GetEnvironmentVariable("ALZ_$($parameterKey)") + if($null -eq $variableValue) { + if($parameter.type -eq "SwitchParameter") { + $variableValue = $parameter.value.IsPresent + } else { + $variableValue = $parameter.value + } + } + + if($parameter.type -eq "SwitchParameter") { + $variableValue = [bool]::Parse($variableValue) + } + Write-Verbose "Adding parameter $parameterKey with value $variableValue" + $inputConfig | Add-Member -NotePropertyName $parameterKey -NotePropertyValue $variableValue + } + } + + return $inputConfig +} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 b/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 index 8844c86a..24b672d6 100644 --- a/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 +++ b/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 @@ -1,14 +1,12 @@ function Get-ALZConfig { - <# - - #> param( [Parameter(Mandatory = $false)] [string] $configFilePath = "" ) if(!(Test-Path $configFilePath)) { - return $null + Write-Error "The config file does not exist at $configFilePath" + throw "The config file does not exist at $configFilePath" } # Import the config and transform it to a PowerShell object @@ -20,7 +18,7 @@ function Get-ALZConfig { Install-Module powershell-Yaml -Force } try { - $config = [PSCustomObject](Get-Content -Path $configFilePath | ConvertFrom-Yaml) + $config = [PSCustomObject](Get-Content -Path $configFilePath | ConvertFrom-Yaml -Ordered) } catch { $errorMessage = "Failed to parse YAML inputs. Please check the YAML file for errors and try again. $_" Write-Error $errorMessage diff --git a/src/ALZ/Private/Config-Helpers/Request-ALZEnvironmentConfig.ps1 b/src/ALZ/Private/Config-Helpers/Request-ALZEnvironmentConfig.ps1 deleted file mode 100644 index 38314a92..00000000 --- a/src/ALZ/Private/Config-Helpers/Request-ALZEnvironmentConfig.ps1 +++ /dev/null @@ -1,109 +0,0 @@ - -function Request-ALZEnvironmentConfig { - param( - [Parameter(Mandatory = $true)] - [object] $configurationParameters, - [Parameter(Mandatory = $false)] - [switch] $respectOrdering, - [Parameter(Mandatory = $false)] - [PSCustomObject] $userInputOverrides = $null, - [Parameter(Mandatory = $false)] - [PSCustomObject] $userInputDefaultOverrides = $null, - [Parameter(Mandatory = $false)] - [System.Boolean] $treatEmptyDefaultAsValid = $false, - [Parameter(Mandatory = $false)] - [switch] $autoApprove, - [Parameter(Mandatory = $false)] - [PSCustomObject] $computedInputs = $null - - ) - <# - .SYNOPSIS - This function uses a template configuration to prompt for and return a user specified/modified configuration object. - .EXAMPLE - Request-ALZEnvironmentConfig - .EXAMPLE - Request-ALZEnvironmentConfig -alzIacProvider "bicep" - .OUTPUTS - System.Object. The resultant configuration values. - #> - - $configurations = $configurationParameters.PsObject.Properties - - $hasInputOverrides = $false - if($userInputOverrides -ne $null) { - $hasInputOverrides = $true - } - - $hasDefaultOverrides = $false - if($userInputDefaultOverrides -ne $null) { - $hasDefaultOverrides = $true - $useDefaults = "" - if(!$hasInputOverrides) { - Write-InformationColored "We found you have cached values from a previous run." -ForegroundColor Yellow -InformationAction Continue - if($autoApprove) { - $useDefaults = "use" - } else { - $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/verify)" - } - } - if($useDefaults.ToLower() -eq "use") { - $userInputOverrides = $userInputDefaultOverrides - } - } - - if($respectOrdering) { - $configurations = $configurationParameters.PSObject.Properties | Sort-Object { $_.Value.Order } - } - - if($null -ne $computedInputs) { - Write-Verbose $computedInputs - } - foreach ($configurationValue in $configurations) { - $computedInput = $null - if($null -ne $computedInputs) { - $computedInput = $computedInputs.PsObject.Properties | Where-Object { $_.Name -eq $configurationValue.Name } - } - - if($null -ne $computedInput) { - $configurationValue.Value.Value = $computedInput.Value.Value - continue - } - - if ($configurationValue.Value.Type -eq "UserInput") { - - # Check for and add cached as default - if(!$hasInputOverrides -and $hasDefaultOverrides) { - $defaultOverride = $userInputDefaultOverrides.PsObject.Properties | Where-Object { $_.Name -eq $configurationValue.Name } - if($null -ne $defaultOverride) { - if(!($configurationValue.Value.PSObject.Properties.Name -match "DefaultValue")) { - $configurationValue.Value | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultOverride.Value - } else { - $configurationValue.Value.DefaultValue = $defaultOverride.Value - } - } - } - - # Check for and use override - if($hasInputOverrides) { - $userInputOverride = $userInputOverrides.PsObject.Properties | Where-Object { $_.Name -eq $configurationValue.Name } - if($null -ne $userInputOverride) { - $configurationValue.Value.Value = $userInputOverride.Value - $configurationValue.Value.Source = "InputConfig" - } else { - if($configurationValue.Value.PSObject.Properties.Name -match "DefaultValue") { - Write-Verbose "Input not supplied, so using default value of $($configurationValue.Value.DefaultValue) for $($configurationValue.Name)" - $configurationValue.Value.Value = $configurationValue.Value.DefaultValue - } else { - Write-Verbose "Input not supplied, and no default for $($configurationValue.Name), so prompting for input..." - Request-ConfigurationValue -configName $configurationValue.Name -configValue $configurationValue.Value -treatEmptyDefaultAsValid $treatEmptyDefaultAsValid - } - } - } else { - Request-ConfigurationValue -configName $configurationValue.Name -configValue $configurationValue.Value -treatEmptyDefaultAsValid $treatEmptyDefaultAsValid - } - } - } - - return $configurationParameters -} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Request-ConfigurationValue.ps1 b/src/ALZ/Private/Config-Helpers/Request-ConfigurationValue.ps1 deleted file mode 100644 index 175a96af..00000000 --- a/src/ALZ/Private/Config-Helpers/Request-ConfigurationValue.ps1 +++ /dev/null @@ -1,117 +0,0 @@ -function Request-ConfigurationValue { - param( - [Parameter(Mandatory = $true)] - [string] $configName, - - [Parameter(Mandatory = $true)] - [object] $configValue, - - [Parameter(Mandatory = $false)] - [System.Boolean] $withRetries = $true, - - [Parameter(Mandatory = $false)] - [System.Boolean] $treatEmptyDefaultAsValid = $false - ) - - #if the file has a script - execute it: - if ($null -ne $configValue.AllowedValues -and $configValue.AllowedValues.Type -eq "PSScript") { - Write-InformationColored $configValue.AllowedValues.Description -ForegroundColor Yellow -InformationAction Continue - $script = [System.Management.Automation.ScriptBlock]::Create($configValue.AllowedValues.Script) - $configValue.AllowedValues.Values = Invoke-Command -ScriptBlock $script - } - - $allowedValues = $configValue.AllowedValues.Values - $hasAllowedValues = $null -ne $configValue.AllowedValues -and $null -ne $configValue.AllowedValues.Values -and $configValue.AllowedValues.Values.Length -gt 0 - - $defaultValue = $configValue.DefaultValue - $hasDefaultValue = $null -ne $configValue.DefaultValue - - $hasValidator = $null -ne $configValue.Valid - - Write-InformationColored $configValue.Description -ForegroundColor White -InformationAction Continue - if ($hasAllowedValues -and $configValue.AllowedValues.Display -eq $true) { - Write-InformationColored "[allowed: $allowedValues] " -ForegroundColor Yellow -InformationAction Continue - } - - $dataType = $configValue.DataType - Write-Verbose "Data Type: $dataType" - - $attempt = 0 - $maxAttempts = 10 - - do { - Write-InformationColored "$($configName) " -ForegroundColor Yellow -NoNewline -InformationAction Continue - if ($hasDefaultValue) { - $displayDefaultValue = $defaultValue -eq "" ? "''" : $defaultValue - if($configValue.Sensitive -and $defaultValue -ne "") { - $displayDefaultValue = "" - } - Write-InformationColored "(default: ${displayDefaultValue}): " -ForegroundColor Yellow -NoNewline -InformationAction Continue - } else { - Write-InformationColored ": " -NoNewline -InformationAction Continue - } - - if($configValue.Sensitive) { - $readValue = Read-Host -MaskInput - } else { - $readValue = Read-Host - } - - if ($hasDefaultValue -and $readValue -eq "") { - $configValue.Value = $configValue.defaultValue - } else { - $configValue.Value = $readValue - } - - $valuesToCheck = @( $configValue.Value ) - if($dataType -eq "list(string)") { - $valuesToCheck = ($configValue.Value -split ",").Trim() | Where-Object {$_ -ne ''} - $configValue.Value = $valuesToCheck -join "," - } - - $isValid = $false - - foreach($valueToCheck in $valuesToCheck) { - $isValid = $true - - $hasNotSpecifiedValue = ($null -eq $valueToCheck -or "" -eq $valueToCheck) -and ($valueToCheck -ne $configValue.DefaultValue) - - if($hasNotSpecifiedValue) { - Write-InformationColored "A value must be specified for this input. It cannot be left empty." -ForegroundColor Red -InformationAction Continue - $isValid = $false - break - } - - $skipValidationForEmptyDefault = $treatEmptyDefaultAsValid -and $hasDefaultValue -and (($defaultValue -eq "" -and $valueToCheck -eq "")) - if(!$skipValidationForEmptyDefault) { - if($hasAllowedValues) { - Write-Verbose "Checking '$($valueToCheck)' against list '$($allowedValues)'" - $isValid = $allowedValues.Contains($valueToCheck) - if(!$isValid) { - Write-InformationColored "The input value '$valueToCheck' is not valid. It must be in the allowed list: '$($allowedValues)'" -ForegroundColor Red -InformationAction Continue - break - } - } - - if($hasValidator) { - Write-Verbose "Checking '$($valueToCheck)' against validator '$($configValue.Valid)'" - $isValid = $valueToCheck -match $configValue.Valid - if(!$isValid) { - Write-InformationColored "The input value '$valueToCheck' is not valid. It must match to specified regular expression: '$($configValue.Valid)'" -ForegroundColor Red -InformationAction Continue - break - } - } - } - } - - $shouldRetry = !$isValid -and $withRetries - - $attempt += 1 - } - while ($shouldRetry -and $attempt -lt $maxAttempts) - - if($attempt -eq $maxAttempts) { - Write-InformationColored "Max attempts reached for getting input value. Exiting..." -ForegroundColor Red -InformationAction Continue - throw "Max attempts reached for getting input value. Exiting..." - } -} diff --git a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 b/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 index b82d61d9..8c10aec1 100644 --- a/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 +++ b/src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1 @@ -8,10 +8,7 @@ function Request-SpecialInput { [PSCustomObject] $starterConfig, [Parameter(Mandatory = $false)] - [PSCustomObject] $bootstrapModules, - - [Parameter(Mandatory = $false)] - [PSCustomObject] $userInputOverrides = $null + [PSCustomObject] $bootstrapModules ) if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) { @@ -55,15 +52,46 @@ function Request-SpecialInput { $typeDescription = "starter module" } - if($null -ne $userInputOverrides) { - $userInputOverride = $userInputOverrides.PSObject.Properties | Where-Object { $_.Name -eq $type } - if($null -ne $userInputOverride) { - $result = $userInputOverride.Value - if($options.key -notcontains $result -and $aliasOptions.key -notcontains $result) { - Write-InformationColored "The $typeDescription '$result' that you have selected does not exist. Please try again with a valid $typeDescription..." -ForegroundColor Red -InformationAction Continue - throw "The $typeDescription '$result' that you have selected does not exist. Please try again with a valid $typeDescription..." + if($type -eq "inputConfigFilePath") { + $retryCount = 0 + $maxRetryCount = 3 + + if($IsWindows) { + $filePath = "" + + while($filePath -ne "OK" -and $retryCount -lt $maxRetryCount) { + Add-Type -AssemblyName System.Windows.Forms + $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ + InitialDirectory = [Environment]::GetFolderPath("MyComputer") + Filter = "YAML or JSON (*.yml;*.yaml;*.json)|*.yml;*.yaml;*.json" + Title = "Select your input configuration file..." + } + $filePath = $FileBrowser.ShowDialog() + if($filePath -eq "OK") { + $result = $FileBrowser.FileName + return $result + } else { + $retryCount++ + Write-InformationColored "You must select a file to continue..." -ForegroundColor Red -InformationAction Continue + } } - return $result + } else { + $validPath = $false + while(-not $validPath -and $retryCount -lt $maxRetryCount) { + $result = Read-Host "Please enter the path to your input configuration file..." + if(Test-Path $result) { + $validPath = $true + return $result + } else { + $retryCount++ + Write-InformationColored "The path '$result' that you have entered does not exist. Please try again with a valid path..." -ForegroundColor Red -InformationAction Continue + } + } + } + + if($retryCount -eq $maxRetryCount) { + Write-InformationColored "You have exceeded the maximum number of retries. Exiting..." -ForegroundColor Red -InformationAction Continue + throw "You have exceeded the maximum number of retries. Exiting..." } } diff --git a/src/ALZ/Private/Config-Helpers/Set-ComputedConfiguration.ps1 b/src/ALZ/Private/Config-Helpers/Set-ComputedConfiguration.ps1 index 75b8fb0c..d0095023 100644 --- a/src/ALZ/Private/Config-Helpers/Set-ComputedConfiguration.ps1 +++ b/src/ALZ/Private/Config-Helpers/Set-ComputedConfiguration.ps1 @@ -8,7 +8,7 @@ function Set-ComputedConfiguration { if ($PSCmdlet.ShouldProcess("ALZ-Bicep computed configuration.", "calculate computed values")) { foreach ($configKey in $configuration.PsObject.Properties) { - if (@("ComputedInput", "Computed") -notcontains $configKey.Value.Type) { + if ("calculated" -ne $configKey.Value.Source) { continue; } @@ -26,7 +26,6 @@ function Set-ComputedConfiguration { $configKey.Value.Value = $formattedValues } else { - $formattedValue = Format-TokenizedConfigurationString -tokenizedString $configKey.Value.Value -configuration $configuration if ($null -ne $configKey.Value.Process) { diff --git a/src/ALZ/Private/Config-Helpers/Set-Config.ps1 b/src/ALZ/Private/Config-Helpers/Set-Config.ps1 new file mode 100644 index 00000000..a7f95225 --- /dev/null +++ b/src/ALZ/Private/Config-Helpers/Set-Config.ps1 @@ -0,0 +1,94 @@ + +function Set-Config { + [CmdletBinding(SupportsShouldProcess = $true)] + param( + [Parameter(Mandatory = $true)] + [object] $configurationParameters, + [Parameter(Mandatory = $false)] + [PSCustomObject] $inputConfig = $null, + [Parameter(Mandatory = $false)] + [switch] $copyEnvVarToConfig + ) + + if ($PSCmdlet.ShouldProcess("Set Configuration.", "Set configuration values.")) { + + $configurations = $configurationParameters.PsObject.Properties + + foreach ($configurationValue in $configurations) { + + # Check for calculated configuration + if($configurationValue.Value.Source -eq "calculated") { + $configurationValue.Value.Value = $configurationValue.Value.Pattern + continue + } + + # Get input config name + $inputConfigName = $configurationValue.Name + if($configurationValue.Value.PSObject.Properties.Name -contains "SourceInput") { + $inputConfigName = $configurationValue.Value.SourceInput + Write-Verbose "Using source input $inputConfigName for $($configurationValue.Name)" + } + + # Look for environment variables + $environmentVariable = [Environment]::GetEnvironmentVariable("TF_VAR_$inputConfigName") + if($null -ne $environmentVariable) { + if($copyEnvVarToConfig) { + $configurationValue.Value.Value = $environmentVariable + Write-Verbose "Set value from environment variable for $inputConfigName" + } else { + $configurationValue.Value.Value = "sourced-from-env" + Write-Verbose "Using environment variable for $inputConfigName" + } + continue + } + + # Look for array config match + if($inputConfigName.EndsWith("]")) { + $indexSplit = $inputConfigName.Split([char[]]@('[', ']'), [System.StringSplitOptions]::RemoveEmptyEntries) + $inputConfigItem = $inputConfig.PsObject.Properties | Where-Object { $_.Name -eq $indexSplit[0] } + if($null -ne $inputConfigItem) { + if(!$inputConfigItem.Value.GetType().ImplementedInterfaces.Contains([System.Collections.ICollection])) { + Write-Error "Input config item $($inputConfigName) is not an array, but an index was specified." + throw "Input config item $($inputConfigName) is not an array, but an index was specified." + } + $index = [int]$indexSplit[1] + if($inputConfigItem.Value.Length -le $index) { + Write-Verbose "Input config item $($inputConfigName) does not have an index of $index." + } else { + $inputConfigItemValue = $inputConfigItem.Value[$index] + if($null -ne $inputConfigItemValue) { + $configurationValue.Value.Value = $inputConfigItemValue + continue + } else { + Write-Verbose "Input config item $($inputConfigName) with index $index is null." + } + } + } else { + Write-Error "Input config item $($inputConfigName) not found." + throw "Input config item $($inputConfigName) not found." + } + } + + # Look for input config match + $inputConfigItem = $inputConfig.PsObject.Properties | Where-Object { $_.Name -eq $inputConfigName } + if($null -ne $inputConfigItem) { + $configurationValue.Value.Value = $inputConfigItem.Value + continue + } + + # TODO: Add validation here... + + # Use the default value if no input config is supplied + if($configurationValue.Value.PSObject.Properties.Name -match "DefaultValue") { + Write-Verbose "Input not supplied, so using default value of $($configurationValue.Value.DefaultValue) for $($configurationValue.Name)" + $configurationValue.Value.Value = $configurationValue.Value.DefaultValue + continue + } + + Write-InformationColored "Input not supplied, and no default for $($configurationValue.Name)..." -ForegroundColor Red -InformationAction Continue + throw "Input not supplied, and no default for $($configurationValue.Name)..." + } + + return $configurationParameters + } +} diff --git a/src/ALZ/Private/Config-Helpers/Write-ConfigurationCache.ps1 b/src/ALZ/Private/Config-Helpers/Write-ConfigurationCache.ps1 deleted file mode 100644 index a7fa3f6c..00000000 --- a/src/ALZ/Private/Config-Helpers/Write-ConfigurationCache.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -function Write-ConfigurationCache { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string] $filePath, - - [Parameter(Mandatory = $false)] - [PSObject] $configuration - ) - - if ($PSCmdlet.ShouldProcess("Download Terraform Tools", "modify")) { - - if(Test-Path $filePath) { - Remove-Item -Path $filePath - } - - $cache = [PSCustomObject]@{} - foreach ($configurationItem in $configuration.PSObject.Properties) { - if($configurationItem.Value.Type -eq "ComputedInput") { - continue - } - $cache | Add-Member -NotePropertyName $configurationItem.Name -NotePropertyValue $configurationItem.Value.Value - } - - $cache | ConvertTo-Json | Out-File -FilePath $filePath - } -} \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Write-JsonFile.ps1 b/src/ALZ/Private/Config-Helpers/Write-JsonFile.ps1 index 572687f7..fba6e228 100644 --- a/src/ALZ/Private/Config-Helpers/Write-JsonFile.ps1 +++ b/src/ALZ/Private/Config-Helpers/Write-JsonFile.ps1 @@ -14,9 +14,9 @@ function Write-JsonFile { Remove-Item -Path $jsonFilePath } - $environmentVariables = @{} + $environmentVariables = [ordered]@{} - foreach ($configKey in $configuration.PsObject.Properties) { + foreach ($configKey in $configuration.PsObject.Properties | Sort-Object Name) { foreach ($target in $configKey.Value.Targets) { if($target.Destination -eq "Environment") { $environmentVariables.$($target.Name) = $configKey.Value.Value @@ -24,7 +24,7 @@ function Write-JsonFile { } } - $json = ConvertTo-Json -InputObject $environmentVariables -Depth 10 + $json = ConvertTo-Json -InputObject $environmentVariables -Depth 100 $json | Out-File -FilePath $jsonFilePath } } \ No newline at end of file diff --git a/src/ALZ/Private/Config-Helpers/Write-TfvarsJsonFile.ps1 b/src/ALZ/Private/Config-Helpers/Write-TfvarsJsonFile.ps1 index ff8655d9..f68f8e27 100644 --- a/src/ALZ/Private/Config-Helpers/Write-TfvarsJsonFile.ps1 +++ b/src/ALZ/Private/Config-Helpers/Write-TfvarsJsonFile.ps1 @@ -14,38 +14,23 @@ function Write-TfvarsJsonFile { Remove-Item -Path $tfvarsFilePath } - $jsonObject = @{} + $jsonObject = [ordered]@{} - foreach($configurationProperty in $configuration.PSObject.Properties) { + foreach($configurationProperty in $configuration.PSObject.Properties | Sort-Object Name) { $configurationValue = $configurationProperty.Value.Value - if($configurationProperty.Value.Validator -eq "configuration_file_path") { - $configurationValue = [System.IO.Path]::GetFileName($configurationValue) + if($configurationValue -eq "sourced-from-env") { + continue } - if($configurationProperty.Value.Source -eq "UserInterface") { - if($configurationProperty.Value.DataType -eq "list(string)") { - if($configurationValue -eq "") { - $configurationValue = @() - } else { - $configurationValue = @($configurationValue -split ",") - } - } - - if($configurationProperty.Value.DataType -eq "number") { - $configurationValue = [int]($configurationValue) - } - - if($configurationProperty.Value.DataType -eq "bool") { - $configurationValue = [bool]($configurationValue) - } + if($configurationProperty.Value.Validator -eq "configuration_file_path") { + $configurationValue = [System.IO.Path]::GetFileName($configurationValue) } $jsonObject["$($configurationProperty.Name)"] = $configurationValue } - $jsonString = ConvertTo-Json $jsonObject - + $jsonString = ConvertTo-Json $jsonObject -Depth 100 $jsonString | Out-File $tfvarsFilePath } } \ No newline at end of file diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 index a0340db8..449a46d4 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Get-BootstrapAndStarterConfig.ps1 @@ -11,7 +11,7 @@ function Get-BootstrapAndStarterConfig { [Parameter(Mandatory = $false)] [string]$bootstrapConfigPath, [Parameter(Mandatory = $false)] - [PSCustomObject]$userInputOverrides, + [PSCustomObject]$inputConfig, [Parameter(Mandatory = $false)] [string]$toolsPath ) @@ -26,7 +26,6 @@ function Get-BootstrapAndStarterConfig { $bootstrapDetails = $null $validationConfig = $null $zonesSupport = $null - $inputConfig = $null # Get the bootstap configuration $bootstrapConfigFullPath = Join-Path $bootstrapPath $bootstrapConfigPath @@ -34,10 +33,10 @@ function Get-BootstrapAndStarterConfig { $bootstrapConfig = Get-ALZConfig -configFilePath $bootstrapConfigFullPath $validationConfig = $bootstrapConfig.validators + # Get the supported regions and availability zones Write-Verbose "Getting Supported Regions and Availability Zones with Terraform" $regionsAndZones = Get-AzureRegionData -toolsPath $toolsPath Write-Verbose "Supported Regions: $($regionsAndZones.supportedRegions)" - $zonesSupport = $regionsAndZones.zonesSupport $azureLocationValidator = $validationConfig.PSObject.Properties["azure_location"].Value $azureLocationValidator.AllowedValues.Values = $regionsAndZones.supportedRegions @@ -45,11 +44,6 @@ function Get-BootstrapAndStarterConfig { # Get the available bootstrap modules $bootstrapModules = $bootstrapConfig.bootstrap_modules - # Request the bootstrap type if not already specified - if($bootstrap -eq "") { - $bootstrap = Request-SpecialInput -type "bootstrap" -bootstrapModules $bootstrapModules -userInputOverrides $userInputOverrides - } - # Get the bootstrap details and validate it exists (use alias for legacy values) $bootstrapDetails = $bootstrapModules.PsObject.Properties | Where-Object { $_.Name -eq $bootstrap -or $bootstrap -in $_.Value.aliases } if($null -eq $bootstrapDetails) { @@ -77,11 +71,6 @@ function Get-BootstrapAndStarterConfig { $starterConfigFilePath = $starterModuleDetails.Value.$iac.release_artifact_config_file } - # Get the bootstrap interface user input config - $inputConfigFilePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapDetails.Value.interface_config_file - Write-Verbose "Interface config path $inputConfigFilePath" - $inputConfig = Get-ALZConfig -configFilePath $inputConfigFilePath - return @{ bootstrapDetails = $bootstrapDetails hasStarterModule = $hasStarterModule @@ -91,7 +80,6 @@ function Get-BootstrapAndStarterConfig { starterConfigFilePath = $starterConfigFilePath validationConfig = $validationConfig zonesSupport = $zonesSupport - inputConfig = $inputConfig } } } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1 index 442f700a..05dc1854 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1 @@ -10,21 +10,6 @@ function Invoke-FullUpgrade { [Parameter(Mandatory = $false)] [string] $bootstrapModuleFolder, - [Parameter(Mandatory = $false)] - [string] $starterRelease, - - [Parameter(Mandatory = $false)] - [string] $starterPath, - - [Parameter(Mandatory = $false)] - [string] $interfaceCacheFileName, - - [Parameter(Mandatory = $false)] - [string] $bootstrapCacheFileName, - - [Parameter(Mandatory = $false)] - [string] $starterCacheFileName, - [Parameter(Mandatory = $false)] [switch] $autoApprove ) @@ -41,30 +26,6 @@ function Invoke-FullUpgrade { -autoApprove:$autoApprove.IsPresent if($bootstrapWasUpgraded) { - # Run upgrade for interface inputs - Invoke-Upgrade ` - -targetDirectory $bootstrapPath ` - -cacheFileName $interfaceCacheFileName ` - -release $bootstrapRelease ` - -autoApprove:$bootstrapWasUpgraded | Out-String | Write-Verbose - - # Run upgrade for bootstrap inputs - Invoke-Upgrade ` - -targetDirectory $bootstrapPath ` - -cacheFileName $bootstrapCacheFileName ` - -release $bootstrapRelease ` - -autoApprove:$bootstrapWasUpgraded | Out-String | Write-Verbose - } - - # Run upgrade for starter - $starterWasUpgraded = Invoke-Upgrade ` - -moduleType "starter" ` - -targetDirectory $starterPath ` - -cacheFileName $starterCacheFileName ` - -release $starterRelease ` - -autoApprove:$autoApprove.IsPresent | Out-String | Write-Verbose - - if($starterWasUpgraded -or $bootstrapWasUpgraded) { Write-InformationColored "AUTOMATIC UPGRADE: Upgrade complete. If any starter files have been updated, you will need to remove branch protection in order for the Terraform apply to succeed." -NewLineBefore -ForegroundColor Yellow -InformationAction Continue } } diff --git a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 index ac1a3ee6..2184200b 100644 --- a/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 +++ b/src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1 @@ -13,9 +13,6 @@ function New-Bootstrap { [Parameter(Mandatory = $false)] [PSCustomObject] $inputConfig, - [Parameter(Mandatory = $false)] - [PSCustomObject] $userInputOverrides = $null, - [Parameter(Mandatory = $false)] [string] $bootstrapTargetPath, @@ -40,276 +37,110 @@ function New-Bootstrap { [Parameter(Mandatory = $false)] [switch] $destroy, - [Parameter(Mandatory = $false)] - [string] $starter = "", - [Parameter(Mandatory = $false)] [PSCustomObject] $zonesSupport = $null, - [Parameter(Mandatory = $false)] - [hashtable] $computedInputs, - [Parameter(Mandatory = $false, HelpMessage = "An extra level of logging that is turned off by default for easier debugging.")] [switch] $writeVerboseLogs, - [Parameter(Mandatory = $false, HelpMessage = "The path to the bootstrap terraform.tfvars file that you would like to replace the default one with. (e.g. c:\accelerator\terraform.tfvars)")] + [Parameter(Mandatory = $false)] [string] - $bootstrapTfVarsOverridePath + $hclParserToolPath ) if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) { $bootstrapPath = Join-Path $bootstrapTargetPath $bootstrapRelease $starterPath = Join-Path $starterTargetPath $starterRelease - - # Setup tools - $hclParserToolPath = Get-HCLParserTool -alzEnvironmentDestination $bootstrapPath -toolVersion "v0.6.0" - - # Setup Cache File Names - $interfaceCacheFileName = "interface-cache.json" - $bootstrapCacheFileName = "bootstrap-cache.json" - $starterCacheFileName = "starter-cache.json" - $interfaceCachePath = Join-Path -Path $bootstrapPath -ChildPath $interfaceCacheFileName - $bootstrapCachePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapCacheFileName - $starterCachePath = Join-Path -Path $starterPath -ChildPath $starterCacheFileName $bootstrapModulePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapDetails.Value.location Write-Verbose "Bootstrap Module Path: $bootstrapModulePath" - # Override default tfvars file - if($bootstrapTfVarsOverridePath -ne "" -and (Test-Path $bootstrapTfVarsOverridePath)) { - $fileExtension = [System.IO.Path]::GetExtension($bootstrapTfVarsOverridePath) - $terraformTfVars = Get-Content $bootstrapTfVarsOverridePath - $targetTfVarsFileName = "terraform.tfvars" - $targetTfVarsPath = Join-Path $bootstrapModulePath $targetTfVarsFileName - - if(Test-Path $targetTfVarsPath) { - Write-Verbose "Removing $targetTfVarsPath" - Remove-Item $targetTfVarsPath -Force | Write-Verbose - } - - if($fileExtension.ToLower() -eq "json") { - $targetTfVarsPath = "$targetTfVarsPath.json" - } - - Write-Verbose "Creating $targetTfVarsPath" - $terraformTfVars | Out-File $targetTfVarsPath -Force - } - # Run upgrade Invoke-FullUpgrade ` -bootstrapModuleFolder $bootstrapDetails.Value.location ` -bootstrapRelease $bootstrapRelease ` -bootstrapPath $bootstrapTargetPath ` - -starterRelease $starterRelease ` - -starterPath $starterTargetPath ` - -interfaceCacheFileName $interfaceCacheFileName ` - -bootstrapCacheFileName $bootstrapCacheFileName ` - -starterCacheFileName $starterCacheFileName ` -autoApprove:$autoApprove.IsPresent - # Get cached inputs - $interfaceCachedConfig = Get-ALZConfig -configFilePath $interfaceCachePath - $bootstrapCachedConfig = Get-ALZConfig -configFilePath $bootstrapCachePath - $starterCachedConfig = Get-ALZConfig -configFilePath $starterCachePath - # Get starter module $starterModulePath = "" if($hasStarter) { - if($starter -eq "") { - $starter = Request-SpecialInput -type "starter" -starterConfig $starterConfig -userInputOverrides $userInputOverrides + if($inputConfig.starter_module_name -eq "") { + $inputConfig.starter_module_name = Request-SpecialInput -type "starter" -starterConfig $starterConfig } - Write-Verbose "Selected Starter: $starter" - - $starterModulePath = (Resolve-Path (Join-Path -Path $starterPath -ChildPath $starterConfig.starter_modules.$starter.location)).Path - + Write-Verbose "Selected Starter: $($inputConfig.starter_module_name))" + $starterModulePath = (Resolve-Path (Join-Path -Path $starterPath -ChildPath $starterConfig.starter_modules.$($inputConfig.starter_module_name).location)).Path Write-Verbose "Starter Module Path: $starterModulePath" } - # Getting the configuration for the interface user input - Write-Verbose "Getting the interface configuration for user input..." - $inputConfigMapped = Convert-InterfaceInputToUserInputConfig -inputConfig $inputConfig -validators $validationConfig - # Getting configuration for the bootstrap module user input $bootstrapParameters = [PSCustomObject]@{} - Write-Verbose "Getting the bootstrap configuration for user input..." - foreach($inputVariablesFile in $bootstrapDetails.Value.input_variable_files) { - $inputVariablesFilePath = Join-Path -Path $bootstrapModulePath -ChildPath $inputVariablesFile - $bootstrapParameters = Convert-HCLVariablesToUserInputConfig -targetVariableFile $inputVariablesFilePath -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $bootstrapParameters - } - Write-Verbose "Getting the bootstrap configuration computed interface input..." - foreach($interfaceVariablesFile in $bootstrapDetails.Value.interface_variable_files) { - $inputVariablesFilePath = Join-Path -Path $bootstrapModulePath -ChildPath $interfaceVariablesFile - $bootstrapParameters = Convert-HCLVariablesToUserInputConfig -targetVariableFile $inputVariablesFilePath -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $bootstrapParameters -allComputedInputs + Write-Verbose "Getting the bootstrap configuration..." + $terraformFiles = Get-ChildItem -Path $bootstrapModulePath -Filter "*.tf" -File + foreach($terraformFile in $terraformFiles) { + $bootstrapParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $bootstrapParameters } # Getting the configuration for the starter module user input $starterParameters = [PSCustomObject]@{} if($hasStarter) { + Write-Verbose "Getting the starter configuration..." if($iac -eq "terraform") { - $targetVariableFilePath = Join-Path -Path $starterModulePath -ChildPath "variables.tf" - $starterParameters = Convert-HCLVariablesToUserInputConfig -targetVariableFile $targetVariableFilePath -hclParserToolPath $hclParserToolPath -validators $validationConfig - } - - if($iac -eq "bicep") { - $starterParameters = Convert-InterfaceInputToUserInputConfig -inputConfig $starterConfig.starter_modules.$starter -validators $validationConfig - } - } - - # Filter interface inputs if not in bootstrap or starter - foreach($inputConfigItem in $inputConfig.inputs.PSObject.Properties) { - if($inputConfigItem.Value.source -ne "input" -or $inputConfigItem.Value.required -eq $true) { - continue - } - $inputVariable = $inputConfigMapped.PSObject.Properties | Where-Object { $_.Name -eq $inputConfigItem.Name } - $displayMapFilter = $inputConfigItem.Value.PSObject.Properties | Where-Object { $_.Name -eq "display_map_filter" } - $hasDisplayMapFilter = $null -ne $displayMapFilter - Write-Verbose "$($inputConfigItem.Name) has display map filter $hasDisplayMapFilter" - - $inBootstrapOrStarter = $false - if("bootstrap" -in $inputConfigItem.Value.maps_to) { - $checkFilter = !$hasDisplayMapFilter -or ($hasDisplayMapFilter -and "bootstrap" -in $displayMapFilter.Value) - - if($checkFilter) { - Write-Verbose "Checking bootstrap for $($inputConfigItem.Name)" - $boostrapParameter = $bootstrapParameters.PSObject.Properties | Where-Object { $_.Name -eq $inputVariable.Name } - if($null -ne $boostrapParameter) { - $inBootstrapOrStarter = $true - } - } - } - if("starter" -in $inputConfigItem.Value.maps_to) { - $checkFilter = !$hasDisplayMapFilter -or ($hasDisplayMapFilter -and "starter" -in $displayMapFilter.Value) - - if($checkFilter) { - Write-Verbose "Checking starter for $($inputConfigItem.Name)" - $starterParameter = $starterParameters.PSObject.Properties | Where-Object { $_.Name -eq $inputVariable.Name } - if($null -ne $starterParameter) { - $inBootstrapOrStarter = $true - } + $terraformFiles = Get-ChildItem -Path $starterModulePath -Filter "*.tf" -File + foreach($terraformFile in $terraformFiles) { + $starterParameters = Convert-HCLVariablesToInputConfig -targetVariableFile $terraformFile.FullName -hclParserToolPath $hclParserToolPath -validators $validationConfig -appendToObject $starterParameters } } - if(!$inBootstrapOrStarter) { - $inputVariable.Value.Type = "SkippedInput" + if($iac -eq "bicep") { + $starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.$($inputConfig.starter_module_name) -validators $validationConfig } } - # Prompt user for interface inputs - Write-InformationColored "The following shared inputs are for the '$($bootstrapDetails.Name)' bootstrap and '$starter' starter module that you selected:" -ForegroundColor Green -NewLineBefore -InformationAction Continue - $interfaceConfiguration = Request-ALZEnvironmentConfig ` - -configurationParameters $inputConfigMapped ` - -respectOrdering ` - -userInputOverrides $userInputOverrides ` - -userInputDefaultOverrides $interfaceCachedConfig ` - -treatEmptyDefaultAsValid $true ` - -autoApprove:$autoApprove.IsPresent + # Set computed inputs + $inputConfig | Add-Member -NotePropertyName "module_folder_path" -NotePropertyValue $starterModulePath + $inputConfig | Add-Member -NotePropertyName "availability_zones_bootstrap" -NotePropertyValue @(Get-AvailabilityZonesSupport -region $inputConfig.bootstrap_location -zonesSupport $zonesSupport) - # Set computed interface inputs - $computedInputs["starter_module_name"] = $starter - $computedInputs["module_folder_path"] = $starterModulePath - $computedInputs["availability_zones_bootstrap"] = @(Get-AvailabilityZonesSupport -region $interfaceConfiguration.bootstrap_location.Value -zonesSupport $zonesSupport) - - if($interfaceConfiguration.starter_locations.Value.Length -gt 0) { - $computedInputs["availability_zones_starter"] = @() - foreach($region in $interfaceConfiguration.starter_locations.Value -split ",") { - $computedInputs["availability_zones_starter"] += @{ - region = $region - zones = @(Get-AvailabilityZonesSupport -region $region -zonesSupport $zonesSupport) - } - } - } else { - $computedInputs["availability_zones_starter"] = @(Get-AvailabilityZonesSupport -region $interfaceConfiguration.starter_location.Value -zonesSupport $zonesSupport) + if($inputConfig.PSObject.Properties.Name -contains "starter_location" -and $inputConfig.PSObject.Properties.Name -notcontains "starter_locations") { + Write-Verbose "Converting starter_location $($inputConfig.starter_location) to starter_locations..." + $inputConfig | Add-Member -NotePropertyName "starter_locations" -NotePropertyValue @($inputConfig.starter_location) } - foreach($inputConfigItem in $inputConfig.inputs.PSObject.Properties) { - if($inputConfigItem.Value.source -eq "powershell") { - $inputVariable = $interfaceConfiguration.PSObject.Properties | Where-Object { $_.Name -eq $inputConfigItem.Name } - $inputValue = $computedInputs[$inputConfigItem.Name] - if($inputValue -is [array]) { - $jsonInputValue = ConvertTo-Json $inputValue -Depth 10 - Write-Verbose "Setting computed interface input array $($inputConfigItem.Name) to $jsonInputValue" - } else { - Write-Verbose "Setting computed interface input string $($inputConfigItem.Name) to $inputValue" - } - $inputVariable.Value.Value = $inputValue + if($inputConfig.PSObject.Properties.Name -contains "starter_locations") { + $availabilityZonesStarter = @() + foreach($region in $inputConfig.starter_locations) { + $availabilityZonesStarter += , @(Get-AvailabilityZonesSupport -region $region -zonesSupport $zonesSupport) } + $inputConfig | Add-Member -NotePropertyName "availability_zones_starter" -NotePropertyValue $availabilityZonesStarter } - # Split interface inputs - $bootstrapComputed = [PSCustomObject]@{} - $starterComputed = [PSCustomObject]@{} + Write-Verbose "Final Input config: $(ConvertTo-Json $inputConfig -Depth 100)" - foreach($inputConfigItem in $inputConfig.inputs.PSObject.Properties) { - $inputVariable = $interfaceConfiguration.PSObject.Properties | Where-Object { $_.Name -eq $inputConfigItem.Name } - if("bootstrap" -in $inputConfigItem.Value.maps_to) { - $bootstrapComputed | Add-Member -NotePropertyName $inputVariable.Name -NotePropertyValue $inputVariable.Value - } - - if("starter" -in $inputConfigItem.Value.maps_to) { - if($iac -eq "terraform") { - $starterComputed | Add-Member -NotePropertyName $inputVariable.Name -NotePropertyValue $inputVariable.Value - } - - if($iac -eq "bicep") { - if($inputConfigItem.Value.PSObject.Properties.Name -contains "bicep_alias") { - Write-Verbose "Setting computed bicep alias $($inputConfigItem.Value.bicep_alias)" - $starterComputed | Add-Member -NotePropertyName $inputConfigItem.Value.bicep_alias -NotePropertyValue $inputVariable.Value - } else { - $starterComputed | Add-Member -NotePropertyName $inputVariable.Name -NotePropertyValue $inputVariable.Value - } - } - } - } - - # Getting the user input for the bootstrap module - Write-InformationColored "The following inputs are specific to the '$($bootstrapDetails.Name)' bootstrap module that you selected:" -ForegroundColor Green -NewLineBefore -InformationAction Continue - $bootstrapConfiguration = Request-ALZEnvironmentConfig ` + # Getting the input for the bootstrap module + Write-Verbose "Setting the configuration for the bootstrap module..." + $bootstrapConfiguration = Set-Config ` -configurationParameters $bootstrapParameters ` - -respectOrdering ` - -userInputOverrides $userInputOverrides ` - -userInputDefaultOverrides $bootstrapCachedConfig ` - -treatEmptyDefaultAsValid $true ` - -autoApprove:$autoApprove.IsPresent ` - -computedInputs $bootstrapComputed - - # Getting the user input for the starter module - Write-InformationColored "The following inputs are specific to the '$starter' starter module that you selected:" -ForegroundColor Green -NewLineBefore -InformationAction Continue - $starterConfiguration = Request-ALZEnvironmentConfig ` + -inputConfig $inputConfig + + # Getting the input for the starter module + Write-Verbose "Setting the configuration for the starter module..." + $starterConfiguration = Set-Config ` -configurationParameters $starterParameters ` - -respectOrdering ` - -userInputOverrides $userInputOverrides ` - -userInputDefaultOverrides $starterCachedConfig ` - -treatEmptyDefaultAsValid $true ` - -autoApprove:$autoApprove.IsPresent ` - -computedInputs $starterComputed + -inputConfig $inputConfig ` + -copyEnvVarToConfig # Creating the tfvars files for the bootstrap and starter module - $tfVarsFileName = "override.tfvars.json" + $tfVarsFileName = "terraform.tfvars.json" $bootstrapTfvarsPath = Join-Path -Path $bootstrapModulePath -ChildPath $tfVarsFileName $starterTfvarsPath = Join-Path -Path $starterModulePath -ChildPath "terraform.tfvars.json" $starterBicepVarsPath = Join-Path -Path $starterModulePath -ChildPath "parameters.json" - # Add any extra inputs to the bootstrap tfvars on the assumption they are hidden inputs - foreach($input in $userInputOverrides.PSObject.Properties) { - $inputName = $input.Name - $inputValue = $input.Value - - if($bootstrapConfiguration.PSObject.Properties.Name -notcontains $inputName -and $interfaceConfiguration.PSObject.Properties.Name -notcontains $inputName -and $starterConfiguration.PSObject.Properties.Name -notcontains $inputName -and @("bootstrap", "starter", "iac") -notcontains $inputName) { - Write-Verbose "Setting hidden bootstrap variable '$inputName' to '$inputValue'" - $configItem = [PSCustomObject]@{} - $configItem | Add-Member -NotePropertyName "Value" -NotePropertyValue $inputValue - $configItem | Add-Member -NotePropertyName "DataType" -NotePropertyValue "Any" - - $bootstrapConfiguration | Add-Member -NotePropertyName $inputName -NotePropertyValue $configItem - } - } - # Write the tfvars file for the bootstrap and starter module Write-TfvarsJsonFile -tfvarsFilePath $bootstrapTfvarsPath -configuration $bootstrapConfiguration @@ -319,39 +150,34 @@ function New-Bootstrap { } if($iac -eq "bicep") { - Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.$starter.deployment_files + Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.$($inputConfig.starter_module_name).deployment_files Set-ComputedConfiguration -configuration $starterConfiguration Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration # Remove unrequired files - $foldersOrFilesToRetain = $starterConfig.starter_modules.$starter.folders_or_files_to_retain + $foldersOrFilesToRetain = $starterConfig.starter_modules.$($inputConfig.starter_module_name).folders_or_files_to_retain $foldersOrFilesToRetain += "parameters.json" $foldersOrFilesToRetain += "config" $foldersOrFilesToRetain += "starter-cache.json" - foreach($deployment_file in $starterConfig.starter_modules.$starter.deployment_files) { + foreach($deployment_file in $starterConfig.starter_modules.$($inputConfig.starter_module_name).deployment_files) { $foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath } - $subFoldersOrFilesToRemove = $starterConfig.starter_modules.$starter.subfolders_or_files_to_remove + $subFoldersOrFilesToRemove = $starterConfig.starter_modules.$($inputConfig.starter_module_name).subfolders_or_files_to_remove Remove-UnrequiredFileSet -path $starterModulePath -foldersOrFilesToRetain $foldersOrFilesToRetain -subFoldersOrFilesToRemove $subFoldersOrFilesToRemove -writeVerboseLogs:$writeVerboseLogs.IsPresent } - # Caching the bootstrap and starter module values paths for retry / upgrade scenarios - Write-ConfigurationCache -filePath $interfaceCachePath -configuration $interfaceConfiguration - Write-ConfigurationCache -filePath $bootstrapCachePath -configuration $bootstrapConfiguration - Write-ConfigurationCache -filePath $starterCachePath -configuration $starterConfiguration - # Running terraform init and apply Write-InformationColored "Thank you for providing those inputs, we are now initializing and applying Terraform to bootstrap your environment..." -ForegroundColor Green -NewLineBefore -InformationAction Continue if($autoApprove) { - Invoke-Terraform -moduleFolderPath $bootstrapModulePath -tfvarsFileName $tfVarsFileName -autoApprove -destroy:$destroy.IsPresent + Invoke-Terraform -moduleFolderPath $bootstrapModulePath -autoApprove -destroy:$destroy.IsPresent } else { Write-InformationColored "Once the plan is complete you will be prompted to confirm the apply." -ForegroundColor Green -NewLineBefore -InformationAction Continue - Invoke-Terraform -moduleFolderPath $bootstrapModulePath -tfvarsFileName $tfVarsFileName -destroy:$destroy.IsPresent + Invoke-Terraform -moduleFolderPath $bootstrapModulePath -destroy:$destroy.IsPresent } Write-InformationColored "Bootstrap has completed successfully! Thanks for using our tool. Head over to Phase 3 in the documentation to continue..." -ForegroundColor Green -NewLineBefore -InformationAction Continue diff --git a/src/ALZ/Private/Legacy-Bicep/Add-AvailabilityZonesBicepParameters.ps1 b/src/ALZ/Private/Legacy-Bicep/Add-AvailabilityZonesBicepParameters.ps1 deleted file mode 100644 index 503959a1..00000000 --- a/src/ALZ/Private/Legacy-Bicep/Add-AvailabilityZonesBicepParameters.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -function Add-AvailabilityZonesBicepParameter { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $true)] - [Alias("Output")] - [Alias("OutputDirectory")] - [Alias("O")] - [string] $alzEnvironmentDestination, - - [Parameter(Mandatory = $true)] - [PSCustomObject]$zonesSupport - ) - - $parametersConfig = @( - [pscustomobject]@{ - source = "hubNetworking.parameters.all.json"; - parameters = @( - "parAzErGatewayAvailabilityZones.value", - "parAzVpnGatewayAvailabilityZones.value", - "parAzFirewallAvailabilityZones.value" - ) - } - [pscustomobject]@{ - source = "vwanConnectivity.parameters.all.json"; - parameters = @("parVirtualWanHubs.value[0].parAzFirewallAvailabilityZones") - } - ) - - foreach ($parametersFile in $parametersConfig) { - $parametersFilePath = Join-Path -Path $alzEnvironmentDestination "config\custom-parameters\$($parametersFile.source)" - if(!(Test-Path -Path $parametersFilePath)) { - Write-Verbose -Message "The file $parametersFilePath does not exist, so skipping it..." - continue - } - - $parametersFileJsonContent = Get-Content -Path $parametersFilePath -Raw - $bicepConfiguration = $parametersFileJsonContent | ConvertFrom-Json -AsHashtable - - $region = $bicepConfiguration.parameters.parLocation.value - $zones = ($zonesSupport | Where-Object { $_.region -eq $region }).zones - - $parametersFile.parameters | ForEach-Object { - $target = $_ - - Write-Verbose "Attempting to update $($target) in $($parametersFile.source) with '$($zones)'" - - # Find the appropriate item which will be changed in the Bicep file. - # Remove array '[' ']' characters so we can use the index value direct. - $propertyNames = $target.Replace("[", ".").Replace("]", "").Replace("..", ".") -split "\." - $bicepConfigNode = $bicepConfiguration.parameters - $index = 0 - - # Keep navigating into properties which the configuration specifies until we reach the bottom most object, - # e.g. not a value type - but the object reference so the value is persisted. - do { - if ($bicepConfigNode -is [array]) { - # If this is an array - use the property as an array index... - if ($propertyNames[$index] -match "[0-9]+" -eq $false) { - throw "Configuration specifies an array, but the index value '${$propertyNames[$index]}' is not a number" - } - - $bicepConfigNode = $bicepConfigNode[$propertyNames[$index]] - - } elseif ($bicepConfigNode.ContainsKey($propertyNames[$index]) -eq $true) { - # We found the item, keep indexing into the object. - $bicepConfigNode = $bicepConfigNode[$propertyNames[$index]] - } else { - # This property doesn't exist at this level in the hierarchy, - # this isn't the property we're looking for, stop looking. - $bicepConfigNode = $null - } - - ++$index - - } while (($null -ne $bicepConfigNode) -and ($index -lt $propertyNames.Length - 1)) - - # If we're here, we can modify this file and we've got an actual object specified by the Name path value - and we can modify values on it. - if ($null -ne $bicepConfigNode) { - $leafPropertyName = $propertyNames[-1] - Write-Verbose "Attempting to update $($target) in $($parametersFile.source) with '$($zones)'" - $bicepConfigNode[$leafPropertyName] = $zones - } - } - - Write-Verbose "Updating Bicep parameter file: $parametersFilePath" - ConvertTo-Json $bicepConfiguration -Depth 10 | Out-File $parametersFilePath - } -} \ No newline at end of file diff --git a/src/ALZ/Private/Legacy-Bicep/Build-ALZDeploymentEnvFile.ps1 b/src/ALZ/Private/Legacy-Bicep/Build-ALZDeploymentEnvFile.ps1 deleted file mode 100644 index 449316d4..00000000 --- a/src/ALZ/Private/Legacy-Bicep/Build-ALZDeploymentEnvFile.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -function Build-ALZDeploymentEnvFile { - param ( - [Parameter(Mandatory = $true)] - [PSCustomObject] $configuration, - - [Parameter(Mandatory = $false)] - [string] $destination = ".", - - [Parameter(Mandatory = $false)] - [string] $version = "" - ) - <# - .SYNOPSIS - This function uses configuration to build a .env file for use in the deployment pipeline. - .EXAMPLE - Build-ALZDeploymentEnvFile -configuration configuration - .EXAMPLE - Build-ALZDeploymentEnvFile -configuration configuration -destination "." - .OUTPUTS - N/A - #> - - $envFile = Join-Path $destination ".env" - - New-Item -Path $envFile -ItemType file -Force | Out-String | Write-Verbose - - foreach ($configurationValue in $configuration.PsObject.Properties) { - foreach ($target in $configurationValue.Value.Targets) { - if ($target.Destination -eq "Environment") { - Write-Verbose "Creating environment files for: $($configurationValue.Name)" - - if($configurationValue.Name -eq "UpstreamReleaseVersion") { - Add-Content -Path $envFile -Value "$($($target.Name))=`"$version`"" | Out-String | Write-Verbose - } else { - $formattedValue = $configurationValue.Value.Value - Add-Content -Path $envFile -Value "$($($target.Name))=`"$formattedValue`"" | Out-String | Write-Verbose - } - } - } - } -} \ No newline at end of file diff --git a/src/ALZ/Private/Legacy-Bicep/Copy-ALZParametersFile.ps1 b/src/ALZ/Private/Legacy-Bicep/Copy-ALZParametersFile.ps1 deleted file mode 100644 index fe59fa46..00000000 --- a/src/ALZ/Private/Legacy-Bicep/Copy-ALZParametersFile.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -function Copy-ALZParametersFile { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $true)] - [Alias("Output")] - [Alias("OutputDirectory")] - [Alias("O")] - [string] $alzEnvironmentDestination, - - [Parameter(Mandatory = $true)] - [string]$upstreamReleaseDirectory, - - [Parameter(Mandatory = $true)] - [array]$configFiles - ) - foreach ($configFile in $configFiles) { - $sourcePath = Join-Path $upstreamReleaseDirectory $configFile.source - $destinationPath = Join-Path $alzEnvironmentDestination $configFile.destination - if (Test-Path $sourcePath) { - if ($PSCmdlet.ShouldProcess($sourcePath, "Copy")) { - # create destination folder if it does not exists - $destinationFolder = Split-Path -Path $destinationPath -Parent - if (-not (Test-Path $destinationFolder)) { - New-Item -ItemType Directory -Path $destinationFolder -Force | Out-String | Write-Verbose - } - Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force | Out-String | Write-Verbose - } - } else { - Write-Warning "The file $sourcePath does not exist." - } - } -} \ No newline at end of file diff --git a/src/ALZ/Private/Legacy-Bicep/New-ALZDirectoryEnvironment.ps1 b/src/ALZ/Private/Legacy-Bicep/New-ALZDirectoryEnvironment.ps1 deleted file mode 100644 index 9a52e2f9..00000000 --- a/src/ALZ/Private/Legacy-Bicep/New-ALZDirectoryEnvironment.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -function New-ALZDirectoryEnvironment { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $true)] - [Alias("Output")] - [Alias("OutputDirectory")] - [Alias("O")] - [string] $alzEnvironmentDestination, - [string] $alzCicdDestination - ) - # Create destination file structure - $gitHubPipeline = Join-Path $alzEnvironmentDestination ".github" "workflows" - $azureDevOpsPipeline = Join-Path $alzEnvironmentDestination ".azuredevops" "pipelines" - $config = Join-Path $alzEnvironmentDestination "config" - $configModules = Join-Path $alzEnvironmentDestination "config" "custom-modules" - $upstream = Join-Path $alzEnvironmentDestination "upstream-releases" - - New-Item -ItemType Directory -Path $alzEnvironmentDestination -Force | Out-String | Write-Verbose - $cicd = if ($alzCicdDestination -eq "github") { $gitHubPipeline } else { $azureDevOpsPipeline } - New-Item -ItemType Directory -Path $cicd -Force | Out-String | Write-Verbose - New-Item -ItemType Directory -Path $config -Force | Out-String | Write-Verbose - New-Item -ItemType Directory -Path $upstream -Force | Out-String | Write-Verbose - New-Item -ItemType Directory -Path $configModules -Force | Out-String | Write-Verbose -} \ No newline at end of file diff --git a/src/ALZ/Private/Legacy-Bicep/New-ALZEnvironmentBicep.ps1 b/src/ALZ/Private/Legacy-Bicep/New-ALZEnvironmentBicep.ps1 deleted file mode 100644 index 0485aed7..00000000 --- a/src/ALZ/Private/Legacy-Bicep/New-ALZEnvironmentBicep.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -function New-ALZEnvironmentBicep { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $false)] - [string] $targetDirectory, - - [Parameter(Mandatory = $false)] - [string] $upstreamReleaseVersion, - - [Parameter(Mandatory = $false)] - [string] $upstreamReleaseFolderPath, - - [Parameter(Mandatory = $false)] - [PSCustomObject] $userInputOverrides = $null, - - [Parameter(Mandatory = $false)] - [ValidateSet("github", "azuredevops")] - [string] $vcs, - - [Parameter(Mandatory = $false)] - [switch] $local, - - [Parameter(Mandatory = $false)] - [switch] $autoApprove, - - [Parameter(Mandatory = $false)] - [switch] $replaceFiles - ) - - if ($PSCmdlet.ShouldProcess("ALZ-Bicep module configuration", "modify")) { - - New-ALZDirectoryEnvironment -alzEnvironmentDestination $targetDirectory -alzCicdDestination $vcs | Out-String | Write-Verbose - - # Getting the configuration - $configFilePath = Join-Path -Path $upstreamReleaseFolderPath -ChildPath "accelerator/.config/ALZ-Powershell.config.json" - Write-Verbose "Config path: $configFilePath" - $bicepConfig = Get-ALZConfig -configFilePath $configFilePath - - # Check if the configuration directory exists - $configDirectory = Join-Path -Path $targetDirectory -ChildPath "config" - if (-not (Test-Path -Path $configDirectory) -or $replaceFiles.IsPresent) { - Write-InformationColored "Copying ALZ-Bicep module to $targetDirectory" -ForegroundColor Green -InformationAction Continue - Copy-ALZParametersFile -alzEnvironmentDestination $targetDirectory -upstreamReleaseDirectory $upstreamReleaseFolderPath -configFiles $bicepConfig.config_files | Out-String | Write-Verbose - Copy-ALZParametersFile -alzEnvironmentDestination $targetDirectory -upstreamReleaseDirectory $upstreamReleaseFolderPath -configFiles $bicepConfig.cicd.$vcs | Out-String | Write-Verbose - $configuration = Request-ALZEnvironmentConfig -configurationParameters $bicepConfig.parameters -userInputOverrides $userInputOverrides -autoApprove:$autoApprove.IsPresent - - Set-ComputedConfiguration -configuration $configuration | Out-String | Write-Verbose - Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $targetDirectory -configuration $configuration | Out-String | Write-Verbose - Build-ALZDeploymentEnvFile -configuration $configuration -Destination $targetDirectory -version $upstreamReleaseVersion | Out-String | Write-Verbose - Add-AvailabilityZonesBicepParameter -alzEnvironmentDestination $targetDirectory -zonesSupport $bicepConfig.zonesSupport | Out-String | Write-Verbose - - } else { - Write-InformationColored "Configuration directory $configDirectory already exists and the replacefiles parameter is set to $replaceFiles. Will skil overwriting the config directory." -ForegroundColor Yellow -InformationAction Continue - } - if ($local) { - $isGitRepo = Test-ALZGitRepository -alzEnvironmentDestination $targetDirectory -autoApprove:$autoApprove.IsPresent - if (-not $isGitRepo) { - Write-InformationColored "The directory $targetDirectory is not a git repository. Please make sure it is a git repo after initialization." -ForegroundColor Red -InformationAction Continue - } - } - } -} diff --git a/src/ALZ/Private/Legacy-Bicep/Test-ALZGitRepository.ps1 b/src/ALZ/Private/Legacy-Bicep/Test-ALZGitRepository.ps1 deleted file mode 100644 index ecee5ad5..00000000 --- a/src/ALZ/Private/Legacy-Bicep/Test-ALZGitRepository.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -function Test-ALZGitRepository { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory = $true)] - [Alias("Output")] - [Alias("OutputDirectory")] - [Alias("O")] - [string] $alzEnvironmentDestination, - [Parameter(Mandatory = $false)] - [switch] $autoApprove - ) - $gitDirectory = Join-Path $alzEnvironmentDestination ".git" - if (Test-Path $gitDirectory) { - Write-Verbose "The directory $alzEnvironmentDestination is already a git repository." - return $true - } - - $runGitInit = $true - $gitBranch = "main" - - if(!$autoApprove) { - $gitInit = Read-Host "Initialize the directory $alzEnvironmentDestination as a git repository? (y/n)" - if ($gitInit -ieq "y") { - $runGitInit = $true - $gitBranch = Read-Host "Enter the default branch name. (Hit enter to skip and use 'main')" - if ($gitBranch -eq "") { - $gitBranch = "main" - } - } - } - - if($runGitInit -and $PSCmdlet.ShouldProcess("gitrepository", "initialize")) { - git init -b $gitBranch $alzEnvironmentDestination - } - - return $runGitInit -} diff --git a/src/ALZ/Private/Tools/Get-HCLParserTool.ps1 b/src/ALZ/Private/Tools/Get-HCLParserTool.ps1 index dd67942c..9c01d04b 100644 --- a/src/ALZ/Private/Tools/Get-HCLParserTool.ps1 +++ b/src/ALZ/Private/Tools/Get-HCLParserTool.ps1 @@ -2,7 +2,7 @@ function Get-HCLParserTool { [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $false)] - [string] $alzEnvironmentDestination, + [string] $toolsPath, [Parameter(Mandatory = $false)] [string] $toolVersion @@ -11,16 +11,25 @@ function Get-HCLParserTool { if ($PSCmdlet.ShouldProcess("Download Terraform Tools", "modify")) { $osArchitecture = Get-OSArchitecture + $toolFolder = Join-Path -Path $toolsPath -ChildPath "hcl_parser_$($toolVersion)" + + if(!(Test-Path $toolFolder)) { + New-Item -ItemType Directory -Path $toolFolder | Out-String | Write-Verbose + } + $toolFileName = "hcl2json_$($osArchitecture.osAndArchitecture)" if($osArchitecture.os -eq "windows") { $toolFileName = "$($toolFileName).exe" } - $toolFilePath = Join-Path -Path $alzEnvironmentDestination -ChildPath $toolFileName + $toolFilePath = Join-Path -Path $toolFolder -ChildPath $toolFileName if(!(Test-Path $toolFilePath)) { - Invoke-WebRequest -Uri "https://github.com/tmccombs/hcl2json/releases/download/$($toolVersion)/$($toolFileName)" -OutFile "$toolFilePath" | Out-String | Write-Verbose + + $uri = "https://github.com/tmccombs/hcl2json/releases/download/$($toolVersion)/$($toolFileName)" + Write-Verbose "Downloading Terraform HCL parser Tool from $uri" + Invoke-WebRequest -Uri $uri -OutFile "$toolFilePath" | Out-String | Write-Verbose } if($osArchitecture.os -ne "windows") { diff --git a/src/ALZ/Public/New-ALZEnvironment.ps1 b/src/ALZ/Public/New-ALZEnvironment.ps1 index 06730e09..00357f6b 100644 --- a/src/ALZ/Public/New-ALZEnvironment.ps1 +++ b/src/ALZ/Public/New-ALZEnvironment.ps1 @@ -4,119 +4,155 @@ function New-ALZEnvironment { Deploys an accelerator according to the supplied inputs. .DESCRIPTION This function is used to deploy accelerators consisting or bootstrap and optionally starter modules. The accelerators are designed to simplify and speed up configuration of common Microsoft patterns, such as CI / CD for Azure Landing Zones. - .PARAMETER output - The target directory for the accelerator artifacts. Depending on the choice and type of accelerlerator, this may be an intermediate stage or the final result of the accelerator. - .PARAMETER iac - The type of infrastructure as code that the accelerator implements. For example bicep or terraform. - .PARAMETER bootstrap - The accelerator bootstrap type to deploy. - .PARAMETER alzIacProvider - The IaC provider to use for the ALZ environment. - .PARAMETER inputs - A json or yaml file containing user input. This will cause the tool to by-pass requesting user input for the inputs supplied in the file. This is useful for automation or defining the inputs up front. - .PARAMETER autoApprove - Automatically approve the bootstrap deployment. This is useful for automation scenarios. - .PARAMETER destroy - Setting this will case the bootstrap to be destroyed. This is useful for cleaning up test environments. .EXAMPLE Deploy-Accelerator .EXAMPLE - Deploy-Accelerator -o "." - .EXAMPLE - Deploy-Accelerator -o "." -i "bicep" -b "alz_github" + Deploy-Accelerator -c "./config.yaml" -o "." #> [CmdletBinding(SupportsShouldProcess = $true)] param ( - [Parameter(Mandatory = $false, HelpMessage = "The target directory for the accelerator output. Defaults to current folder.")] - [Alias("Output")] - [Alias("OutputDirectory")] - [Alias("O")] - [Alias("alzEnvironmentDestination")] - [string] $targetDirectory = ".", - - [Parameter(Mandatory = $false, HelpMessage = "The specific bootstrap module release version to download. Defaults to latest.")] - [string] $bootstrapRelease = "latest", - - [Parameter(Mandatory = $false, HelpMessage = "The specific starter module release version tom download. Defaults to latest.")] - [Alias("alzBicepVersion")] - [Alias("version")] - [Alias("v")] - [Alias("alzVersion")] - [Alias("release")] - [string] $starterRelease = "latest", + [Parameter( + Mandatory = $false, + HelpMessage = "[REQUIRED] The configuration inputs in json or yaml format. Environment variable: ALZ_input_config_path" + )] + [Alias("inputs")] + [Alias("c")] + [string] $inputConfigFilePath = $env:ALZ_input_config_path ?? "", - [Parameter(Mandatory = $false, HelpMessage = "The infrastructure as code type to target. Supported options are 'bicep', 'terrform' or 'local'. You will be prompted to enter this if not supplied.")] + [Parameter( + Mandatory = $false, + HelpMessage = "[REQUIRED] The infrastructure as code type to target. Supported options are 'bicep', 'terrform' or 'local'. Environment variable: ALZ_iac_type. Config file input: iac_type.")] [Alias("i")] - [Alias("alzIacProvider")] - [string] $iac = "", + [Alias("iac")] + [string] $iac_type = "", - [Parameter(Mandatory = $false, HelpMessage = "The bootstrap module to deploy. You will be prompted to enter this if not supplied.")] - [Alias("Cicd")] - [Alias("c")] - [Alias("alzCicdPlatform")] + [Parameter( + Mandatory = $false, + HelpMessage = "[REQUIRED] The bootstrap module to deploy. Environment variable: ALZ_bootstrap_module_name. Config file input: bootstrap_module_name." + )] [Alias("b")] - [string] $bootstrap = "", - - [Parameter(Mandatory = $false, HelpMessage = "The starter module to deploy. You will be prompted to enter this if not supplied.")] - [string] $starter = "", - - [Parameter(Mandatory = $false, HelpMessage = "The inputs in json or yaml format. This is optional and used to automate or pre-prepare the accelerator inputs.")] - [Alias("inputs")] - [string] $userInputOverridePath = "", - - [Parameter(Mandatory = $false, HelpMessage = "Determines whether to deploy the bootstrap without prompting for approval. This is used for automation.")] - [switch] $autoApprove, - - [Parameter(Mandatory = $false, HelpMessage = "Determines that this run is to destroup the bootstrap. This is used to cleanup experiments.")] + [Alias("bootstrap")] + [string] $bootstrap_module_name = "", + + [Parameter( + Mandatory = $false, + HelpMessage = "[REQUIRED] The starter module to deploy. Environment variable: ALZ_starter_module_name. Config file input: starter_module_name." + )] + [Alias("s")] + [Alias("starter")] + [string] $starter_module_name = "", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The target directory for the accelerator working set of files. Defaults to current working folder. Environment variable: ALZ_output_folder_path. Config file input: output_folder_path." + )] + [Alias("output")] + [Alias("o")] + [Alias("targetDirectory")] + [string] $output_folder_path = ".", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The version tag of the bootstrap module release to download. Defaults to latest. Environment variable: ALZ_bootstrap_module_version. Config file input: bootstrap_module_version." + )] + [Alias("bv")] + [Alias("bootstrapRelease")] + [string] $bootstrap_module_version = "latest", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The version tag of the starter module release to download. Defaults to latest. Environment variable: ALZ_starter_module_version. Config file input: starter_module_version." + )] + [Alias("sv")] + [Alias("starterRelease")] + [string] $starter_module_version = "latest", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Determines whether to deploy the bootstrap without prompting for approval. This is used for automation. Environment variable: ALZ_auto_approve. Config file input: auto_approve." + )] + [Alias("aa")] + [Alias("autoApprove")] + [switch] $auto_approve, + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Determines that this run is to destroup the bootstrap. This is used to cleanup experiments. Environment variable: ALZ_destroy. Config file input: destroy." + )] + [Alias("d")] [switch] $destroy, - [Parameter(Mandatory = $false, HelpMessage = "The bootstrap modules reposiotry url. This can be overridden for custom modules.")] - [string] - $bootstrapModuleUrl = "https://github.com/Azure/accelerator-bootstrap-modules", - - [Parameter(Mandatory = $false, HelpMessage = "The bootstrap modules release artifact name.")] - [string] - $bootstrapModuleReleaseArtifactName = "bootstrap_modules.zip", - - [Parameter(Mandatory = $false, HelpMessage = "The bootstrap config file path within the bootstrap module. This can be overridden for custom modules.")] - [string] - $bootstrapConfigPath = ".config/ALZ-Powershell.config.json", - - [Parameter(Mandatory = $false, HelpMessage = "The folder that containes the bootstrap modules in the bootstrap repo. This can be overridden for custom modules.")] - [string] - $bootstrapSourceFolder = ".", - - [Parameter(Mandatory = $false, HelpMessage = "Used to override the bootstrap folder location. This can be used to provide a folder locally in restricted environments.")] - [string] - $bootstrapModuleOverrideFolderPath = "", - - [Parameter(Mandatory = $false, HelpMessage = "Used to override the starter folder location. This can be used to provide a folder locally in restricted environments.")] - [string] - $starterModuleOverrideFolderPath = "", - - [Parameter(Mandatory = $false, HelpMessage = "The starter module repository url for bicep when running in legacy mode.")] - [string] - $bicepLegacyUrl = "https://github.com/Azure/ALZ-Bicep", - - [Parameter(Mandatory = $false, HelpMessage = "Whether to skip checks that involve internet connection. The can allow running in restricted environments.")] - [switch] - $skipInternetChecks, - - [Parameter(Mandatory = $false, HelpMessage = "Whether to use legacy local mode for Bicep.")] - [bool] - $bicepLegacyMode = $false, - - [Parameter(Mandatory = $false, HelpMessage = "Whether to overwrite bootstrap and starter modules if they already exist. Warning, this may result in unexpected behaviour and should only be used for local development purposes.")] - [switch] - $replaceFiles, - - [Parameter(Mandatory = $false, HelpMessage = "An extra level of logging that is turned off by default for easier debugging.")] - [switch] - $writeVerboseLogs, - - [Parameter(Mandatory = $false, HelpMessage = "The path to the bootstrap terraform.tfvars file that you would like to replace the default one with. (e.g. c:\accelerator\terraform.tfvars). This file can also be in json format.")] - [string] - $bootstrapTfVarsOverridePath + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The bootstrap modules reposiotry url. This can be overridden for custom modules. Environment variable: ALZ_bootstrap_module_url. Config file input: bootstrap_module_url." + )] + [Alias("bu")] + [Alias("bootstrapModuleUrl")] + [string] $bootstrap_module_url = "https://github.com/Azure/accelerator-bootstrap-modules", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The bootstrap modules release artifact name. This can be overridden for custom modules. Environment variable: ALZ_bootstrap_module_release_artifact_name. Config file input: bootstrap_module_release_artifact_name." + )] + [Alias("ba")] + [Alias("bootstrapModuleReleaseArtifactName")] + [string] $bootstrap_module_release_artifact_name = "bootstrap_modules.zip", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The bootstrap config file path within the bootstrap module. This can be overridden for custom modules. Environment variable: ALZ_bootstrap_config_path. Config file input: bootstrap_config_path." + )] + [Alias("bc")] + [Alias("bootstrapConfigPath")] + [string] $bootstrap_config_path = ".config/ALZ-Powershell.config.json", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] The folder that containes the bootstrap modules in the bootstrap repo. This can be overridden for custom modules. Environment variable: ALZ_bootstrap_source_folder. Config file input: bootstrap_source_folder." + )] + [Alias("bf")] + [Alias("bootstrapSourceFolder")] + [string] $bootstrap_source_folder = ".", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Used to override the bootstrap folder source. This can be used to provide a folder locally in restricted environments or dev. Environment variable: ALZ_bootstrapModuleOverrideFolderPath. Config file input: bootstrapModuleOverrideFolderPath." + )] + [Alias("bo")] + [Alias("bootstrapModuleOverrideFolderPath")] + [string] $bootstrap_module_override_folder_path = "", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Used to override the starter folder source. This can be used to provide a folder locally in restricted environments. Environment variable: ALZ_starterModuleOverrideFolderPath. Config file input: starterModuleOverrideFolderPath." + )] + [Alias("so")] + [Alias("starterModuleOverrideFolderPath")] + [string] $starter_module_override_folder_path = "", + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Whether to skip checks that involve internet connection. The can allow running in restricted environments. Environment variable: ALZ_skip_internet_checks. Config file input: skip_internet_checks." + )] + [Alias("si")] + [Alias("skipInternetChecks")] + [switch] $skip_internet_checks, + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] Whether to overwrite bootstrap and starter modules if they already exist. Warning, this may result in unexpected behaviour and should only be used for local development purposes. Environment variable: ALZ_replace_files. Config file input: replace_files." + )] + [Alias("rf")] + [Alias("replaceFiles")] + [switch] $replace_files, + + [Parameter( + Mandatory = $false, + HelpMessage = "[OPTIONAL] An extra level of logging that is turned off by default for easier debugging. Environment variable: ALZ_write_verbose_logs. Config file input: writeVerboseLogs." + )] + [Alias("v")] + [Alias("writeVerboseLogs")] + [switch] $write_verbose_logs ) $ProgressPreference = "SilentlyContinue" @@ -124,43 +160,53 @@ function New-ALZEnvironment { Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -InformationAction Continue if ($PSCmdlet.ShouldProcess("Accelerator setup", "modify")) { - # Get User Inputs from the -inputs file - $userInputOverrides = $null - if ($userInputOverridePath -ne "") { - $userInputOverrides = Get-ALZConfig -configFilePath $userInputOverridePath - } - # Get the IAC type if not specified - if ($iac -eq "") { - $iac = Request-SpecialInput -type "iac" -userInputOverrides $userInputOverrides + # Get User Inputs from the input config file + $inputConfig = $null + if ($inputConfigFilePath -eq "") { + Write-InformationColored "No input configuration file path has been provided. Please provide the path to your configuration file..." -ForegroundColor Yellow -InformationAction Continue + $inputConfigFilePath = Request-SpecialInput -type "inputConfigFilePath" } + $inputConfig = Get-ALZConfig -configFilePath $inputConfigFilePath + Write-Verbose "Initial Input config: $(ConvertTo-Json $inputConfig -Depth 100)" + + # Set accelerator input config from input file, environment variables or parameters + $parameters = (Get-Command -Name $MyInvocation.InvocationName).Parameters + $parametersWithValues = @{} + foreach ($parameterKey in $parameters.Keys) { + $parameter = $parameters[$parameterKey] + if($parameter.IsDynamic) { + continue + } - # Setup the Bicep flag - $isLegacyBicep = $false - if ($iac -eq "bicep") { - $isLegacyBicep = $bicepLegacyMode -eq $true - } + $parameterValue = Get-Variable -Name $parameterKey -ValueOnly -ErrorAction SilentlyContinue - if ($isLegacyBicep) { - Write-Verbose "We are running in legacy Bicep mode" + if($null -ne $parameterValue) { + $parametersWithValues[$parameterKey] = @{ + type = $parameters[$parameterKey].ParameterType.Name + value = $parameterValue + aliases = $parameter.Aliases + } + } } + $inputConfig = Convert-ParametersToInputConfig -inputConfig $inputConfig -parameters $parametersWithValues - if (!$isLegacyBicep) { - Write-Verbose "We are running in modern mode" + # Get the IAC type if not specified + if ($inputConfig.iac_type -eq "") { + $inputConfig.iac_type = Request-SpecialInput -type "iac" } # Check and install Terraform CLI if needed - $toolsPath = Join-Path -Path $targetDirectory -ChildPath ".tools" - if(!$isLegacyBicep) { - if($skipInternetChecks) { - Write-InformationColored "Skipping Terraform tool check as you used the skipInternetCheck parameter. Please ensure you have the most recent version of Terraform installed" -ForegroundColor Yellow -InformationAction Continue - } else { - Write-InformationColored "Checking you have the latest version of Terraform installed..." -ForegroundColor Green -NewLineBefore -InformationAction Continue - if ($iac -eq "bicep") { - Write-InformationColored "Although you have selected Bicep, the Accelerator leverages the Terraform tool to bootstrap your Version Control System and Azure. This is will not impact your choice of Bicep post this initial bootstrap. Please refer to our documentation for further details..." -ForegroundColor Yellow -InformationAction Continue - } - Get-TerraformTool -version "latest" -toolsPath $toolsPath + $toolsPath = Join-Path -Path $inputConfig.output_folder_path -ChildPath ".tools" + if($skipInternetChecks) { + Write-InformationColored "Skipping Terraform tool check as you used the skipInternetCheck parameter. Please ensure you have the most recent version of Terraform installed" -ForegroundColor Yellow -InformationAction Continue + } else { + Write-InformationColored "Checking you have the latest version of Terraform installed..." -ForegroundColor Green -NewLineBefore -InformationAction Continue + if ($inputConfig.iac_type -eq "bicep") { + Write-InformationColored "Although you have selected Bicep, the Accelerator leverages the Terraform tool to bootstrap your Version Control System and Azure. This is will not impact your choice of Bicep post this initial bootstrap. Please refer to our documentation for further details..." -ForegroundColor Yellow -InformationAction Continue } + Get-TerraformTool -version "latest" -toolsPath $toolsPath + $hclParserToolPath = Get-HCLParserTool -toolVersion "v0.6.0" -toolsPath $toolsPath } # Download the bootstrap modules @@ -168,32 +214,25 @@ function New-ALZEnvironment { $bootstrapPath = "" $bootstrapTargetFolder = "bootstrap" - if (!$isLegacyBicep) { - Write-InformationColored "Checking and Downloading the bootstrap module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue + Write-InformationColored "Checking and Downloading the bootstrap module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue - $versionAndPath = New-ModuleSetup ` - -targetDirectory $targetDirectory ` - -targetFolder $bootstrapTargetFolder ` - -sourceFolder $bootstrapSourceFolder ` - -url $bootstrapModuleUrl ` - -release $bootstrapRelease ` - -releaseArtifactName $bootstrapModuleReleaseArtifactName ` - -moduleOverrideFolderPath $bootstrapModuleOverrideFolderPath ` - -skipInternetChecks $skipInternetChecks ` - -replaceFile:$replaceFiles.IsPresent - - $bootstrapReleaseTag = $versionAndPath.releaseTag - $bootstrapPath = $versionAndPath.path - } + $versionAndPath = New-ModuleSetup ` + -targetDirectory $inputConfig.output_folder_path ` + -targetFolder $bootstrapTargetFolder ` + -sourceFolder $inputConfig.bootstrap_source_folder ` + -url $inputConfig.bootstrap_module_url ` + -release $inputConfig.bootstrap_module_version ` + -releaseArtifactName $inputConfig.bootstrap_module_release_artifact_name ` + -moduleOverrideFolderPath $inputConfig.bootstrap_module_override_folder_path ` + -skipInternetChecks $inputConfig.skip_internet_checks ` + -replaceFile:$inputConfig.replace_files + + $bootstrapReleaseTag = $versionAndPath.releaseTag + $bootstrapPath = $versionAndPath.path # Configure the starter module path $starterFolder = "starter" - $starterModuleTargetFolder = $starterFolder - if ($isLegacyBicep) { - $starterModuleTargetFolder = "./upstream-releases" - $starterFolder = "" - } # Setup the variables for bootstrap and starter modules $hasStarterModule = $false @@ -204,112 +243,78 @@ function New-ALZEnvironment { $bootstrapDetails = $null $validationConfig = $null - $inputConfig = $null $zonesSupport = $null - if (!$isLegacyBicep) { - $bootstrapAndStarterConfig = Get-BootstrapAndStarterConfig ` - -iac $iac ` - -bootstrap $bootstrap ` - -bootstrapPath $bootstrapPath ` - -bootstrapConfigPath $bootstrapConfigPath ` - -userInputOverrides $userInputOverrides ` - -toolsPath $toolsPath - - $bootstrapDetails = $bootstrapAndStarterConfig.bootstrapDetails - $hasStarterModule = $bootstrapAndStarterConfig.hasStarterModule - $starterModuleUrl = $bootstrapAndStarterConfig.starterModuleUrl - $starterModuleSourceFolder = $bootstrapAndStarterConfig.starterModuleSourceFolder - $starterReleaseArtifactName = $bootstrapAndStarterConfig.starterReleaseArtifactName - $starterConfigFilePath = $bootstrapAndStarterConfig.starterConfigFilePath - $validationConfig = $bootstrapAndStarterConfig.validationConfig - $inputConfig = $bootstrapAndStarterConfig.inputConfig - $zonesSupport = $bootstrapAndStarterConfig.zonesSupport - } else { - if ($bootstrap -eq "") { - $bootstrap = Request-SpecialInput -type "bootstrap" -bootstrapModules $bootstrapModules -userInputOverrides $userInputOverrides - } + # Request the bootstrap type if not already specified + if($inputConfig.bootstrap_module_name -eq "") { + $inputConfig.bootstrap_module_name = Request-SpecialInput -type "bootstrap" -bootstrapModules $bootstrapModules } + $bootstrapAndStarterConfig = Get-BootstrapAndStarterConfig ` + -iac $inputConfig.iac_type ` + -bootstrap $inputConfig.bootstrap_module_name ` + -bootstrapPath $bootstrapPath ` + -bootstrapConfigPath $inputConfig.bootstrap_config_path ` + -inputConfig $inputConfig ` + -toolsPath $toolsPath + + $bootstrapDetails = $bootstrapAndStarterConfig.bootstrapDetails + $hasStarterModule = $bootstrapAndStarterConfig.hasStarterModule + $starterModuleUrl = $bootstrapAndStarterConfig.starterModuleUrl + $starterModuleSourceFolder = $bootstrapAndStarterConfig.starterModuleSourceFolder + $starterReleaseArtifactName = $bootstrapAndStarterConfig.starterReleaseArtifactName + $starterConfigFilePath = $bootstrapAndStarterConfig.starterConfigFilePath + $validationConfig = $bootstrapAndStarterConfig.validationConfig + $zonesSupport = $bootstrapAndStarterConfig.zonesSupport + # Download the starter modules $starterReleaseTag = "" $starterConfig = $null - if (($hasStarterModule -or $isLegacyBicep)) { + if ($hasStarterModule) { Write-InformationColored "Checking and downloading the starter module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue $versionAndPath = New-ModuleSetup ` - -targetDirectory $targetDirectory ` + -targetDirectory $inputConfig.output_folder_path ` -targetFolder $starterModuleTargetFolder ` -sourceFolder $starterModuleSourceFolder ` -url $starterModuleUrl ` - -release $starterRelease ` + -release $inputConfig.starter_module_version ` -releaseArtifactName $starterReleaseArtifactName ` - -moduleOverrideFolderPath $starterModuleOverrideFolderPath ` - -skipInternetChecks $skipInternetChecks ` - -replaceFile:$replaceFiles.IsPresent + -moduleOverrideFolderPath $inputConfig.starter_module_override_folder_path ` + -skipInternetChecks $inputConfig.skip_internet_checks ` + -replaceFile:$inputConfig.replace_files $starterReleaseTag = $versionAndPath.releaseTag $starterPath = $versionAndPath.path - if ($starterConfigFilePath -ne "") { - $starterConfig = Get-StarterConfig -starterPath $starterPath -starterConfigPath $starterConfigFilePath - } + $starterConfig = Get-StarterConfig -starterPath $starterPath -starterConfigPath $starterConfigFilePath } - # Run the bicep parameter setup if the iac is Bicep - if ($isLegacyBicep) { - Write-Verbose "Starting the Bicep specific environment setup..." - - $bootstrapLegacy = $bootstrap.ToLower().Replace("alz_", "") - Write-Verbose "Bootstrap legacy: $bootstrapLegacy" - - $targetPath = Join-Path $targetDirectory $starterFolder - Write-Verbose "Target path: $targetPath" - - New-ALZEnvironmentBicep ` - -targetDirectory $targetPath ` - -upstreamReleaseVersion $starterReleaseTag ` - -upstreamReleaseFolderPath $starterPath ` - -vcs $bootstrapLegacy ` - -local:$isLegacyBicep ` - -autoApprove:$autoApprove.IsPresent ` - -userInputOverrides $userInputOverrides - } + # Set computed interface inputs + $inputConfig | Add-Member -MemberType NoteProperty -Name "on_demand_folder_repository" -Value $starterModuleUrl + $inputConfig | Add-Member -MemberType NoteProperty -Name "on_demand_folder_artifact_name" -Value $starterReleaseArtifactName + $inputConfig | Add-Member -MemberType NoteProperty -Name "release_version" -Value ($starterReleaseTag -eq "local" ? $inputConfig.starter_module_version : $starterReleaseTag) # Run the bootstrap - if (!$isLegacyBicep) { - - # Set computed interface inputs - $computedInputs = @{ - "iac_type" = $iac - "on_demand_folder_repository" = $starterModuleUrl - "on_demand_folder_artifact_name" = $starterReleaseArtifactName - "release_version" = $starterReleaseTag -eq "local" ? $starterRelease : $starterReleaseTag - } - - $bootstrapTargetPath = Join-Path $targetDirectory $bootstrapTargetFolder - $starterTargetPath = Join-Path $targetDirectory $starterFolder - - New-Bootstrap ` - -iac $iac ` - -bootstrapDetails $bootstrapDetails ` - -validationConfig $validationConfig ` - -inputConfig $inputConfig ` - -bootstrapTargetPath $bootstrapTargetPath ` - -bootstrapRelease $bootstrapReleaseTag ` - -hasStarter:$hasStarterModule ` - -starterTargetPath $starterTargetPath ` - -starterRelease $starterReleaseTag ` - -starterConfig $starterConfig ` - -userInputOverrides $userInputOverrides ` - -autoApprove:$autoApprove.IsPresent ` - -destroy:$destroy.IsPresent ` - -starter $starter ` - -zonesSupport $zonesSupport ` - -computedInputs $computedInputs ` - -writeVerboseLogs:$writeVerboseLogs.IsPresent ` - -bootstrapTfVarsOverridePath $bootstrapTfVarsOverridePath - } + $bootstrapTargetPath = Join-Path $inputConfig.output_folder_path $bootstrapTargetFolder + $starterTargetPath = Join-Path $inputConfig.output_folder_path $starterFolder + + New-Bootstrap ` + -iac $inputConfig.iac_type ` + -bootstrapDetails $bootstrapDetails ` + -validationConfig $validationConfig ` + -inputConfig $inputConfig ` + -bootstrapTargetPath $bootstrapTargetPath ` + -bootstrapRelease $bootstrapReleaseTag ` + -hasStarter:$hasStarterModule ` + -starterTargetPath $starterTargetPath ` + -starterRelease $starterReleaseTag ` + -starterConfig $starterConfig ` + -autoApprove:$inputConfig.auto_approve ` + -destroy:$inputConfig.destroy ` + -zonesSupport $zonesSupport ` + -writeVerboseLogs:$inputConfig.write_verbose_logs ` + -hclParserToolPath $hclParserToolPath } $ProgressPreference = "Continue" diff --git a/src/PSScriptAnalyzerSettings.psd1 b/src/PSScriptAnalyzerSettings.psd1 index 8e9fa5f3..cf51f490 100644 --- a/src/PSScriptAnalyzerSettings.psd1 +++ b/src/PSScriptAnalyzerSettings.psd1 @@ -19,7 +19,8 @@ #ExcludeRules #Specify ExcludeRules when you want to exclude a certain rule from the the default set of rules. ExcludeRules = @( - 'PSAvoidUsingWriteHost' + 'PSAvoidUsingWriteHost', + 'PSReviewUnusedParameter' ) #________________________________________ #Rules diff --git a/src/Tests/Unit/Private/Add-AvailabilityZonesBicepParameters.Tests.ps1 b/src/Tests/Unit/Private/Add-AvailabilityZonesBicepParameters.Tests.ps1 deleted file mode 100644 index 603bacfe..00000000 --- a/src/Tests/Unit/Private/Add-AvailabilityZonesBicepParameters.Tests.ps1 +++ /dev/null @@ -1,71 +0,0 @@ -#------------------------------------------------------------------------- -Set-Location -Path $PSScriptRoot -#------------------------------------------------------------------------- -$ModuleName = 'ALZ' -$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") -#------------------------------------------------------------------------- -if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { - #if the module is already in memory, remove it - Remove-Module -Name $ModuleName -Force -} -Import-Module $PathToManifest -Force -#------------------------------------------------------------------------- - -InModuleScope 'ALZ' { - $VerbosePreference = "Continue" - Describe "Add-AvailabilityZonesBicepParameter" { - BeforeAll { - $alzEnvironmentDestination = "TestDrive:\" - $hubParametersPath = "https://raw.githubusercontent.com/Azure/ALZ-Bicep/main/infra-as-code/bicep/modules/hubNetworking/parameters/hubNetworking.parameters.all.json" - New-Item -Path "$alzEnvironmentDestination\config\custom-parameters" -Force -ItemType Directory - Invoke-WebRequest -Uri $hubParametersPath -OutFile "$alzEnvironmentDestination\config\custom-parameters\hubNetworking.parameters.all.json" - } - Context "Hub networking parameters availability zones check" { - It "Should add 3 availability zones for hub networking parameters" { - Add-AvailabilityZonesBicepParameter -alzEnvironmentDestination $alzEnvironmentDestination -zonesSupport (@( - [PSCustomObject]@{ - region = "eastus" - zones = @("1", "2", "3") - } - ) - ) - $parametersFileJsonContent = Get-Content -Path "TestDrive:\config\custom-parameters\hubNetworking.parameters.all.json" -Raw - Write-Verbose (Test-Path -Path "TestDrive:\config\custom-parameters\hubNetworking.parameters.all.json") - #Write-Verbose $parametersFileJsonContent - $jsonObject = $parametersFileJsonContent | ConvertFrom-Json - $jsonObject.parameters.parAzErGatewayAvailabilityZones.value | Should -Be @("1", "2", "3") - $jsonObject.parameters.parAzVpnGatewayAvailabilityZones.value | Should -Be @("1", "2", "3") - $jsonObject.parameters.parAzFirewallAvailabilityZones.value | Should -Be @("1", "2", "3") - } - It "Should add 2 availability zones for hub networking parameters" { - Add-AvailabilityZonesBicepParameter -alzEnvironmentDestination $alzEnvironmentDestination -zonesSupport (@( - [PSCustomObject]@{ - region = "eastus" - zones = @("1", "2") - } - ) - ) - $parametersFileJsonContent = Get-Content -Path "TestDrive:\config\custom-parameters\hubNetworking.parameters.all.json" -Raw - $jsonObject = $parametersFileJsonContent | ConvertFrom-Json - $jsonObject.parameters.parAzErGatewayAvailabilityZones.value | Should -Be @("1", "2") - $jsonObject.parameters.parAzVpnGatewayAvailabilityZones.value | Should -Be @("1", "2") - $jsonObject.parameters.parAzFirewallAvailabilityZones.value | Should -Be @("1", "2") - } - It "Should add 0 availability zones for hub networking parameters" { - Add-AvailabilityZonesBicepParameter -alzEnvironmentDestination $alzEnvironmentDestination -zonesSupport (@( - [PSCustomObject]@{ - region = "eastus" - zones = @() - } - ) - ) - $parametersFileJsonContent = Get-Content -Path "TestDrive:\config\custom-parameters\hubNetworking.parameters.all.json" -Raw - $jsonObject = $parametersFileJsonContent | ConvertFrom-Json - $jsonObject.parameters.parAzErGatewayAvailabilityZones.value | Should -Be @() - $jsonObject.parameters.parAzVpnGatewayAvailabilityZones.value | Should -Be @() - $jsonObject.parameters.parAzFirewallAvailabilityZones.value | Should -Be @() - } - } - } - -} \ No newline at end of file diff --git a/src/Tests/Unit/Private/Build-ALZDeploymentEnvFile.Tests.ps1 b/src/Tests/Unit/Private/Build-ALZDeploymentEnvFile.Tests.ps1 deleted file mode 100644 index 4d9cc9e3..00000000 --- a/src/Tests/Unit/Private/Build-ALZDeploymentEnvFile.Tests.ps1 +++ /dev/null @@ -1,82 +0,0 @@ -#------------------------------------------------------------------------- -Set-Location -Path $PSScriptRoot -#------------------------------------------------------------------------- -$ModuleName = 'ALZ' -$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") -#------------------------------------------------------------------------- -if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { - #if the module is already in memory, remove it - Remove-Module -Name $ModuleName -Force -} -Import-Module $PathToManifest -Force -#------------------------------------------------------------------------- - -InModuleScope 'ALZ' { - Describe 'Build-AZLDeploymentEnvFile Private Function Tests' -Tag Unit { - BeforeAll { - $WarningPreference = 'SilentlyContinue' - $ErrorActionPreference = 'SilentlyContinue' - } - Context 'Build-AZLDeploymentEnvFile should create a .env file correctly' { - It 'Creates a config file based on configuration.' { - - Mock -CommandName New-Item - Mock -CommandName Add-Content - - $configuration = [pscustomobject]@{ - Setting1 = [pscustomobject]@{ - Targets = @( - [pscustomobject]@{ - Name = "Setting1" - Destination = "Environment" - }) - Value = "Test1" - } - Setting2 = [pscustomobject]@{ - Targets = @( - [pscustomobject]@{ - Name = "Setting2" - Destination = "Environment" - }) - Value = "Test2" - } - } - - Build-ALZDeploymentEnvFile -configuration $configuration -destination "test" - - Should -Invoke New-Item -ParameterFilter { $Path -match ".env$" } -Scope It -Times 1 -Exactly - Should -Invoke Add-Content -ParameterFilter { $Value -match "^Setting1=`"Test1`"$" } -Scope It -Times 1 -Exactly - Should -Invoke Add-Content -ParameterFilter { $Value -match "^Setting2=`"Test2`"$" } -Scope It -Times 1 -Exactly - } - It 'Omits configuration not intended for the .env file.' { - - Mock -CommandName New-Item - Mock -CommandName Add-Content - - $configuration = [pscustomobject]@{ - Setting1 = [pscustomobject]@{ - Targets = @( - [pscustomobject]@{ - Name = "Setting1" - Destination = "Environment" - }) - Value = "Test1" - } - Setting2 = [pscustomobject]@{ - Targets = @( - [pscustomobject]@{ - Name = "Setting2" - Destination = "Parameters" - }) - Value = "Test2" - } - } - - Build-ALZDeploymentEnvFile -configuration $configuration -destination "test" - - Should -Invoke New-Item -ParameterFilter { $Path -match ".env$" } -Scope It -Times 1 -Exactly - Should -Invoke Add-Content -Scope It -Times 1 -Exactly - } - } - } -} \ No newline at end of file diff --git a/src/Tests/Unit/Private/Edit-ALZConfigurationFilesInPlace.Tests.ps1 b/src/Tests/Unit/Private/Edit-ALZConfigurationFilesInPlace.Tests.ps1 index 5adbcac1..09b5ab1b 100644 --- a/src/Tests/Unit/Private/Edit-ALZConfigurationFilesInPlace.Tests.ps1 +++ b/src/Tests/Unit/Private/Edit-ALZConfigurationFilesInPlace.Tests.ps1 @@ -37,7 +37,7 @@ InModuleScope 'ALZ' { ) $config = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Value = $withValue Targets = @( @@ -148,7 +148,7 @@ InModuleScope 'ALZ' { $config = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Value = @( "1", @@ -399,7 +399,7 @@ InModuleScope 'ALZ' { Value = "dev" } Logging = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "The type of environment that will be created . Example: dev, test, qa, staging, prod" Value = "logs/{%Environment%}/{%Location%}" Targets = @( diff --git a/src/Tests/Unit/Private/New-ALZDirectoryEnvironment.Tests.ps1 b/src/Tests/Unit/Private/New-ALZDirectoryEnvironment.Tests.ps1 deleted file mode 100644 index 2ad6f2b6..00000000 --- a/src/Tests/Unit/Private/New-ALZDirectoryEnvironment.Tests.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -#------------------------------------------------------------------------- -Set-Location -Path $PSScriptRoot -#------------------------------------------------------------------------- -$ModuleName = 'ALZ' -$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") -#------------------------------------------------------------------------- -if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { - #if the module is already in memory, remove it - Remove-Module -Name $ModuleName -Force -} -Import-Module $PathToManifest -Force -#------------------------------------------------------------------------- - -InModuleScope 'ALZ' { - Describe 'New-ALZDirectoryEnvironment Function Tests' -Tag Unit { - BeforeAll { - $WarningPreference = 'SilentlyContinue' - $ErrorActionPreference = 'SilentlyContinue' - } - Context 'Initialize config get the correct base values' { - BeforeEach { - Mock -CommandName New-Item -MockWith { } - } - It 'Should create the correct folder structure' { - $basePath = "./config" - - New-ALZDirectoryEnvironment -OutputDirectory $basePath - Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq './config' } - Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath 'upstream-releases') } -Exactly 1 - Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath '.github' 'workflows') -or $Path -eq $(Join-Path $basePath '.azuredevops' 'pipelines') } -Exactly 1 - Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath 'config') } -Exactly 1 - } - } - } -} diff --git a/src/Tests/Unit/Private/Request-ConfigurationValue.Tests.ps1 b/src/Tests/Unit/Private/Request-ConfigurationValue.Tests.ps1 deleted file mode 100644 index 31138955..00000000 --- a/src/Tests/Unit/Private/Request-ConfigurationValue.Tests.ps1 +++ /dev/null @@ -1,180 +0,0 @@ -#------------------------------------------------------------------------- -Set-Location -Path $PSScriptRoot -#------------------------------------------------------------------------- -$ModuleName = 'ALZ' -$PathToManifest = [System.IO.Path]::Combine('..', '..', '..', $ModuleName, "$ModuleName.psd1") -#------------------------------------------------------------------------- -if (Get-Module -Name $ModuleName -ErrorAction 'SilentlyContinue') { - #if the module is already in memory, remove it - Remove-Module -Name $ModuleName -Force -} -Import-Module $PathToManifest -Force -#------------------------------------------------------------------------- - -InModuleScope 'ALZ' { - Describe 'Request-ConfigurationValue Public Function Tests' -Tag Unit { - BeforeAll { - $WarningPreference = 'SilentlyContinue' - $ErrorActionPreference = 'SilentlyContinue' - } - Context 'User inputs requested value' { - BeforeEach { - Mock -CommandName Write-InformationColored -MockWith { - $null - } - - Mock -CommandName Read-Host -MockWith { - "user input value" - } - } - It 'Prompt the user for configuration with a default value.' { - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - DefaultValue = "alz" - } - - Request-ConfigurationValue -configName "prefix" -configValue $configValue - - Should -Invoke -CommandName Write-InformationColored -Times 3 -Exactly - - $configValue.Value | Should -BeExactly "user input value" - } - - It 'Prompt the user for configuration and providing no value selects the default value.' { - Mock -CommandName Read-Host -MockWith { - "" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - DefaultValue = "alz" - } - - Request-ConfigurationValue -configName "prefix" -configValue $configValue - - Should -Invoke -CommandName Write-InformationColored -Times 3 -Exactly - - $configValue.Value | Should -BeExactly "alz" - } - - It 'Prompt the user with warning text if no value is specified and no default value is present.' { - Mock -CommandName Read-Host -MockWith { - "" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - } - - Request-ConfigurationValue -configName "prefix" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -ParameterFilter { $ForegroundColor -eq "Red" } -Scope It - - $configValue.Value | Should -BeExactly "" - } - - It 'Prompt the user with warning text when an invalid value is specified.' { - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - DefaultValue = "alz" - Valid = "^[a-zA-Z0-9]{2,10}(-[a-zA-Z0-9]{2,10})?$" - } - - Request-ConfigurationValue -configName "prefix" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -ParameterFilter { $ForegroundColor -eq "Red" } -Scope It - } - - It 'Prompt the user with warning text when a value is specified which isnt in the allowed list.' { - Mock -CommandName Read-Host -MockWith { - "notinthelist" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - AllowedValues = @{ - Values = @("alz", "slz") - } - } - Request-ConfigurationValue -configName "prefix" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -ParameterFilter { $ForegroundColor -eq "Red" } -Scope It - } - - It 'Prompt the user with warning text when a value is specified which isnt in the allowed list for a list(string).' { - Mock -CommandName Read-Host -MockWith { - "alz,notinthelist" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - DataType = "list(string)" - Value = "" - AllowedValues = @{ - Values = @("alz", "slz") - } - } - Request-ConfigurationValue -configName "prefix" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -ParameterFilter { $ForegroundColor -eq "Red" } -Scope It - } - - It 'Prompt user with a calculated list of AllowedValues' { - Mock -CommandName Read-Host -MockWith { - "l" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - AllowedValues = @{ - Type = "PSScript" - Values = @() - Script = '"h e l l o" -split " "' - Display = $true - Description = "A collection of values returned by PS Script" - } - } - Request-ConfigurationValue -configName "calculated" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -Times 5 -Exactly - $configValue.Value | Should -BeExactly "l" - } - - It 'Do not display the calculated list of AllowedValues if Display is false' { - Mock -CommandName Read-Host -MockWith { - "l" - } - - $configValue = @{ - Description = "The prefix that will be added to all resources created by this deployment." - Names = @("parTopLevelManagementGroupPrefix", "parCompanyPrefix") - Value = "" - AllowedValues = @{ - Type = "PSScript" - Values = @() - Script = '"h e l l o" -split " "' - Display = $false - Description = "A collection of values returned by PS Script" - } - } - Request-ConfigurationValue -configName "calculated" -configValue $configValue -withRetries $false - - Should -Invoke -CommandName Write-InformationColored -Times 4 -Exactly - $configValue.Value | Should -BeExactly "l" - } - } - } -} diff --git a/src/Tests/Unit/Private/Set-ComputedConfiguration.Tests.ps1 b/src/Tests/Unit/Private/Set-ComputedConfiguration.Tests.ps1 index 34cfa001..bc742ede 100644 --- a/src/Tests/Unit/Private/Set-ComputedConfiguration.Tests.ps1 +++ b/src/Tests/Unit/Private/Set-ComputedConfiguration.Tests.ps1 @@ -34,8 +34,8 @@ InModuleScope 'ALZ' { Name = "Setting2" Destination = "Environment" }) - Type = "Computed" - Value = "{%Setting1%}" + Source = "calculated" + Value = "{%Setting1%}" } } @@ -46,7 +46,7 @@ InModuleScope 'ALZ' { It 'Computed, Processed array values replace values correctly' { $configuration = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Process = '@($args | Select-Object -Unique)' Value = @( @@ -69,7 +69,7 @@ InModuleScope 'ALZ' { It 'Computed, Processed array values replace values correctly in a case insensitive deduplication.' { $configuration = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Process = '@($args | ForEach-Object { $_.ToLower() } | Select-Object -Unique)' Value = @( @@ -93,7 +93,7 @@ InModuleScope 'ALZ' { It 'Computed, Processed array values replace values correctly and keep array type when only one item remains.' { $configuration = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Process = '@($args | Select-Object -Unique)' Value = @( @@ -116,7 +116,7 @@ InModuleScope 'ALZ' { It 'Computed, Processed values replace values correctly' { $configuration = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Process = '($args[0] -eq "eastus") ? "eastus2" : ($args[0] -eq "eastus2") ? "eastus" : $args[0]' Value = "eastus" @@ -135,7 +135,7 @@ InModuleScope 'ALZ' { It 'Computed, Processed values replace values correctly' { $configuration = [pscustomobject]@{ Nested = [pscustomobject]@{ - Type = "Computed" + Source = "calculated" Description = "A Test Value" Process = '($args[0] -eq "goodbye") ? "Hello" : "Goodbye"' Value = "goodbye" diff --git a/src/Tests/Unit/Private/Request-ALZEnvironmentConfig.Tests.ps1 b/src/Tests/Unit/Private/Set-Config.Tests.ps1 similarity index 75% rename from src/Tests/Unit/Private/Request-ALZEnvironmentConfig.Tests.ps1 rename to src/Tests/Unit/Private/Set-Config.Tests.ps1 index 01a0eff5..ee75efdb 100644 --- a/src/Tests/Unit/Private/Request-ALZEnvironmentConfig.Tests.ps1 +++ b/src/Tests/Unit/Private/Set-Config.Tests.ps1 @@ -12,16 +12,14 @@ Import-Module $PathToManifest -Force #------------------------------------------------------------------------- InModuleScope 'ALZ' { - Describe 'Request-ALZEnvironmentConfig Private Function Tests' -Tag Unit { + Describe 'Set-Config Private Function Tests' -Tag Unit { BeforeAll { $WarningPreference = 'SilentlyContinue' $ErrorActionPreference = 'SilentlyContinue' } - Context 'Request-ALZEnvironmentConfig should request CLI input for configuration.' { + Context 'Set-Config should request CLI input for configuration.' { It 'Based on the configuration object' { - Mock -CommandName Request-ConfigurationValue - $config = @' { "parameters":{ @@ -34,15 +32,14 @@ InModuleScope 'ALZ' { "Destination":"Parameters" } ], - "DefaultValue":"alz" + "DefaultValue":"alz", + "Value":"" } } } '@ | ConvertFrom-Json - Request-ALZEnvironmentConfig -configurationParameters $config.Parameters - - Should -Invoke Request-ConfigurationValue -Scope It -Times 1 -Exactly + Set-Config -configurationParameters $config.Parameters } } diff --git a/src/Tests/Unit/Public/New-ALZEnvironment.Tests.ps1 b/src/Tests/Unit/Public/New-ALZEnvironment.Tests.ps1 index ccb049fe..3e671d3d 100644 --- a/src/Tests/Unit/Public/New-ALZEnvironment.Tests.ps1 +++ b/src/Tests/Unit/Public/New-ALZEnvironment.Tests.ps1 @@ -21,7 +21,7 @@ InModuleScope 'ALZ' { } Context 'Success' { BeforeEach { - Mock -CommandName Request-ALZEnvironmentConfig -MockWith { + Mock -CommandName Set-Config -MockWith { @( @{ "description" = "Test configuration 1" @@ -39,9 +39,6 @@ InModuleScope 'ALZ' { } Mock -CommandName Edit-ALZConfigurationFilesInPlace - Mock -CommandName Build-ALZDeploymentEnvFile - - Mock -CommandName New-ALZDirectoryEnvironment -MockWith { } Mock -CommandName Copy-Item -MockWith { } @@ -88,17 +85,13 @@ InModuleScope 'ALZ' { Mock -CommandName Get-GithubRelease -MockWith { $("v0.0.1") } - Mock -CommandName Test-ALZGitRepository -MockWith { $false } - - Mock -CommandName Copy-ALZParametersFile -MockWith { } - Mock -CommandName Write-InformationColored Mock -CommandName Get-HCLParserTool -MockWith { "test" } Mock -CommandName Get-TerraformTool -MockWith { } - Mock -CommandName Convert-HCLVariablesToUserInputConfig -MockWith { + Mock -CommandName Convert-HCLVariablesToInputConfig -MockWith { @( @{ "description" = "Test configuration 1" @@ -115,8 +108,6 @@ InModuleScope 'ALZ' { ) } - Mock -CommandName Write-ConfigurationCache -MockWith { } - Mock -CommandName Invoke-Terraform -MockWith { } Mock -CommandName Invoke-Upgrade -MockWith { } @@ -149,8 +140,6 @@ InModuleScope 'ALZ' { Mock -CommandName New-Bootstrap -MockWith {} - Mock -CommandName New-ALZEnvironmentBicep -MockWith {} - Mock -CommandName Get-AzureRegionData -MockWith { @{ "uksouth" = @{ @@ -161,20 +150,14 @@ InModuleScope 'ALZ' { } } - It 'should call the correct functions for bicep legacy module configuration' { - New-ALZEnvironment -i "bicep" -c "github" -bicepLegacyMode $true - Assert-MockCalled -CommandName New-ALZEnvironmentBicep -Exactly 1 - Assert-MockCalled -CommandName New-ModuleSetup -Exactly 1 - } - - It 'should call the correct functions for bicep modern module configuration' { - Deploy-Accelerator -i "bicep" -c "github" -bicepLegacyMode $false + It 'should call the correct functions for bicep module configuration' { + Deploy-Accelerator -i "bicep" -b "github" -inputs "example.yml" Assert-MockCalled -CommandName Get-BootstrapAndStarterConfig -Exactly 1 Assert-MockCalled -CommandName New-ModuleSetup -Exactly 2 } It 'should call the correct functions for terraform module configuration' { - Deploy-Accelerator -i "terraform" -c "github" + Deploy-Accelerator -i "terraform" -b "github" -inputs "example.yml" Assert-MockCalled -CommandName Get-BootstrapAndStarterConfig -Exactly 1 Assert-MockCalled -CommandName New-Bootstrap -Exactly 1 Assert-MockCalled -CommandName New-ModuleSetup -Exactly 2