From 775b8cf2e2f8e1c3c5737e603ae8b1daf966084e Mon Sep 17 00:00:00 2001 From: Isabelle Bersano <100224087+ibersanoMS@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:24:28 -0500 Subject: [PATCH] [Fix] Terraform - Updates for azurerm v4 (#159) * fix: update deprecated route table input * fix: add sub id as input to azurerm provider * fix: remove sub_id and add env variable instructions to deployment guide --- scenarios/aca-internal/terraform/README.md | 9 +++++++-- .../aca-internal/terraform/modules/01-hub/variables.tf | 1 + .../aca-internal/terraform/modules/02-spoke/variables.tf | 1 + .../modules/03-supporting-services/variables.tf | 1 + .../modules/04-container-apps-environment/variables.tf | 1 + .../modules/05-hello-world-sample-app/variables.tf | 1 + .../modules/06-application-gateway/variables.tf | 1 + scenarios/aca-internal/terraform/providers.tf | 1 - scenarios/aca-internal/terraform/variables.tf | 3 ++- .../terraform/modules/networking/route-table/main.tf | 2 +- 10 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scenarios/aca-internal/terraform/README.md b/scenarios/aca-internal/terraform/README.md index a861fd9f..1bcb5cab 100644 --- a/scenarios/aca-internal/terraform/README.md +++ b/scenarios/aca-internal/terraform/README.md @@ -77,7 +77,7 @@ az storage container-rm create --storage-account $STORAGE_ACCOUNT_NAME --name $C As you configured the backend remote state with your live Azure infrastructure resource values, you must also provide them for your deployment. -The table below summurizes the avaialble parameters and the possible values that can be set. +The table below summarizes the available parameters and the possible values that can be set. | Name | Description | Default | Example(s) | | :---- | :---------- | :------ | :--------- | @@ -148,13 +148,18 @@ Before deploying, you need to decide how you would like to deploy the solution w ### 1. Standalone deployment guide -You can deploy the complete landing zone in a single subscription, by using the [main.tf](main.tf) template file and the accompanying [terraform.tfvars](terraform.tfvars) parameter file. You need first to check and customize the parameter file (parameters are described below) and then decide whether you intend to deploy the simple [Hello World App](modules/05-hello-world-sample-app/README.md) or the more comprehensive, Dapr-enabled [Fine Collection Sample App](sample-apps/java-fine-collection-service/docs/02-container-apps.md). If you intend to deploy the [Fine Collection Sample App](sample-apps/java-fine-collection-service/docs/02-container-apps.md), we reccomend that you set the variable `deployHelloWorldSample` to `false`. +You can deploy the complete landing zone in a single subscription, by using the [main.tf](main.tf) template file and the accompanying [terraform.tfvars](terraform.tfvars) parameter file. You need first to check and customize the parameter file (parameters are described below) and then decide whether you intend to deploy the simple [Hello World App](modules/05-hello-world-sample-app/README.md) or the more comprehensive, Dapr-enabled [Fine Collection Sample App](sample-apps/java-fine-collection-service/docs/02-container-apps.md). If you intend to deploy the [Fine Collection Sample App](sample-apps/java-fine-collection-service/docs/02-container-apps.md), we recommend that you set the variable `deployHelloWorldSample` to `false`. #### Provide parameters required for deployment 1. Review the available variables with their descriptions and default values in the [variables.tf](./variables.tf) file. 2. Provide any custom values to the defined variables by creating a `terraform.tfvars` file in this [directory](terraform.tfvars) * [TF Docs: Variable Definitions (.tfvars) Files](https://www.terraform.io/language/values/variables#variable-definitions-tfvars-files) +> [!NOTE] +> If you are using Azure CLI authentication that is not a service principal or OIDC, the [AzureRM provider](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide) now requires setting the `subscription_id` in the provider. Running the following command in your Bash terminal before moving on to the next commands. +> +> `export ARM_SUBSCRIPTION_ID=00000000-xxxx-xxxx-xxxx-xxxxxxxxxxxx` + #### Bash shell (i.e. inside WSL2 for windows 11, or any linux-based OS) ``` bash terraform init ` diff --git a/scenarios/aca-internal/terraform/modules/01-hub/variables.tf b/scenarios/aca-internal/terraform/modules/01-hub/variables.tf index e13d4c93..f1d61591 100644 --- a/scenarios/aca-internal/terraform/modules/01-hub/variables.tf +++ b/scenarios/aca-internal/terraform/modules/01-hub/variables.tf @@ -1,3 +1,4 @@ + variable "workloadName" { type = string validation { diff --git a/scenarios/aca-internal/terraform/modules/02-spoke/variables.tf b/scenarios/aca-internal/terraform/modules/02-spoke/variables.tf index 65e0e060..fffc78aa 100644 --- a/scenarios/aca-internal/terraform/modules/02-spoke/variables.tf +++ b/scenarios/aca-internal/terraform/modules/02-spoke/variables.tf @@ -1,3 +1,4 @@ + variable "workloadName" { type = string validation { diff --git a/scenarios/aca-internal/terraform/modules/03-supporting-services/variables.tf b/scenarios/aca-internal/terraform/modules/03-supporting-services/variables.tf index e969fd19..e2a2336f 100644 --- a/scenarios/aca-internal/terraform/modules/03-supporting-services/variables.tf +++ b/scenarios/aca-internal/terraform/modules/03-supporting-services/variables.tf @@ -1,6 +1,7 @@ // ------------------ // PARAMETERS // ------------------ + variable "workloadName" { type = string validation { diff --git a/scenarios/aca-internal/terraform/modules/04-container-apps-environment/variables.tf b/scenarios/aca-internal/terraform/modules/04-container-apps-environment/variables.tf index aebabaf6..e4340db8 100644 --- a/scenarios/aca-internal/terraform/modules/04-container-apps-environment/variables.tf +++ b/scenarios/aca-internal/terraform/modules/04-container-apps-environment/variables.tf @@ -1,6 +1,7 @@ // ------------------ // PARAMETERS // ------------------ + variable "workloadName" { type = string validation { diff --git a/scenarios/aca-internal/terraform/modules/05-hello-world-sample-app/variables.tf b/scenarios/aca-internal/terraform/modules/05-hello-world-sample-app/variables.tf index 69511b38..bf68021c 100644 --- a/scenarios/aca-internal/terraform/modules/05-hello-world-sample-app/variables.tf +++ b/scenarios/aca-internal/terraform/modules/05-hello-world-sample-app/variables.tf @@ -1,3 +1,4 @@ + variable "tags" {} variable "helloWorldContainerAppName" { diff --git a/scenarios/aca-internal/terraform/modules/06-application-gateway/variables.tf b/scenarios/aca-internal/terraform/modules/06-application-gateway/variables.tf index e5bad3f3..551f11f1 100644 --- a/scenarios/aca-internal/terraform/modules/06-application-gateway/variables.tf +++ b/scenarios/aca-internal/terraform/modules/06-application-gateway/variables.tf @@ -1,3 +1,4 @@ + variable "appGatewayCertificateKeyName" {} variable "location" {} diff --git a/scenarios/aca-internal/terraform/providers.tf b/scenarios/aca-internal/terraform/providers.tf index 47562b1c..5b308137 100644 --- a/scenarios/aca-internal/terraform/providers.tf +++ b/scenarios/aca-internal/terraform/providers.tf @@ -8,7 +8,6 @@ terraform { } required_version = ">= 1.3.4" - # uncomment if you want to save state file into remote storae account backend "azurerm" { } } diff --git a/scenarios/aca-internal/terraform/variables.tf b/scenarios/aca-internal/terraform/variables.tf index 797cb04b..db902204 100644 --- a/scenarios/aca-internal/terraform/variables.tf +++ b/scenarios/aca-internal/terraform/variables.tf @@ -1,3 +1,4 @@ + variable "workloadName" { type = string validation { @@ -52,7 +53,7 @@ variable "vmAdminPassword" { variable "vmLinuxSshAuthorizedKeys" {} variable "vmLinuxAuthenticationType" { - type = string + type = string default = "password" validation { condition = anytrue([ diff --git a/scenarios/shared/terraform/modules/networking/route-table/main.tf b/scenarios/shared/terraform/modules/networking/route-table/main.tf index 4764834a..fa1fd061 100644 --- a/scenarios/shared/terraform/modules/networking/route-table/main.tf +++ b/scenarios/shared/terraform/modules/networking/route-table/main.tf @@ -2,7 +2,7 @@ resource "azurerm_route_table" "rt" { name = var.routeTableName resource_group_name = var.resourceGroupName location = var.location - disable_bgp_route_propagation = true + bgp_route_propagation_enabled = false tags = var.tags }