From 3a440e0031a9ae8ad3ede758cc7b435adfc07c9c Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 09:57:06 +0800 Subject: [PATCH 01/11] Fix 301-service-fabric-apim --- quickstart/301-service-fabric-apim/azuread.tf | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/quickstart/301-service-fabric-apim/azuread.tf b/quickstart/301-service-fabric-apim/azuread.tf index 2b9b78b23..bb2eb8ded 100644 --- a/quickstart/301-service-fabric-apim/azuread.tf +++ b/quickstart/301-service-fabric-apim/azuread.tf @@ -1,10 +1,10 @@ # Service Fabric Cluster resource "azuread_application" "cluster" { - name = "${var.name}-cluster-${var.environment}" + display_name = "${var.name}-cluster-${var.environment}" } resource "azuread_service_principal" "cluster" { - application_id = "${azuread_application.cluster.application_id}" + application_id = azuread_application.cluster.application_id } resource "random_string" "cluster_password" { @@ -13,35 +13,45 @@ resource "random_string" "cluster_password" { } resource "azuread_service_principal_password" "cluster" { - service_principal_id = "${azuread_service_principal.cluster.id}" - value = "${random_string.cluster_password.result}" + service_principal_id = azuread_service_principal.cluster.id + value = random_string.cluster_password.result end_date = "2099-01-01T01:00:00Z" } +resource "random_uuid" "admin" { +} + +resource "random_uuid" "reader" { +} + # Service Fabric Client resource "azuread_application" "client" { - name = "${var.name}-client-${var.environment}" - reply_urls = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] + display_name = "${var.name}-client-${var.environment}" + redirect_uris = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] app_role { + id = random_uuid.admin.result + allowed_member_types = [ "User", ] description = "Admins can manage roles and perform all task actions" display_name = "Admin" - is_enabled = true + enabled = true value = "Admin" } app_role { + id = random_uuid.reader.result + allowed_member_types = [ "User", ] description = "ReadOnly roles have limited query access" display_name = "ReadOnly" - is_enabled = true + enabled = true value = "User" } @@ -57,7 +67,7 @@ resource "azuread_application" "client" { } resource "azuread_service_principal" "client" { - application_id = "${azuread_application.client.application_id}" + application_id = azuread_application.client.application_id } resource "random_string" "client_password" { @@ -66,7 +76,7 @@ resource "random_string" "client_password" { } resource "azuread_service_principal_password" "client" { - service_principal_id = "${azuread_service_principal.client.id}" - value = "${random_string.client_password.result}" + service_principal_id = azuread_service_principal.client.id + value = random_string.client_password.result end_date = "2099-01-01T01:00:00Z" } From 3237add141316adb3770ceb0b08b9e2f4dc2dba3 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 11:40:44 +0800 Subject: [PATCH 02/11] update code --- quickstart/301-service-fabric-apim/azuread.tf | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/quickstart/301-service-fabric-apim/azuread.tf b/quickstart/301-service-fabric-apim/azuread.tf index bb2eb8ded..4fb11b9f9 100644 --- a/quickstart/301-service-fabric-apim/azuread.tf +++ b/quickstart/301-service-fabric-apim/azuread.tf @@ -26,8 +26,8 @@ resource "random_uuid" "reader" { # Service Fabric Client resource "azuread_application" "client" { - display_name = "${var.name}-client-${var.environment}" - redirect_uris = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] + display_name = "${var.name}-client-${var.environment}" + reply_urls = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] app_role { id = random_uuid.admin.result @@ -70,13 +70,7 @@ resource "azuread_service_principal" "client" { application_id = azuread_application.client.application_id } -resource "random_string" "client_password" { - length = 32 - special = true -} - resource "azuread_service_principal_password" "client" { service_principal_id = azuread_service_principal.client.id - value = random_string.client_password.result end_date = "2099-01-01T01:00:00Z" } From 05e46ad0cfce34e079be4db82ec8f0dc351fa72b Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 11:45:41 +0800 Subject: [PATCH 03/11] update code --- quickstart/301-service-fabric-apim/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstart/301-service-fabric-apim/main.tf b/quickstart/301-service-fabric-apim/main.tf index 66ff3720b..21fe64790 100644 --- a/quickstart/301-service-fabric-apim/main.tf +++ b/quickstart/301-service-fabric-apim/main.tf @@ -4,9 +4,10 @@ data "azurerm_client_config" "current" {} provider "azurerm" { version = "=1.36.1" + features {} } resource "azurerm_resource_group" "default" { name = "${var.name}-${var.environment}-rg" - location = "${var.location}" + location = var.location } From 06d7fb697408a84453643f7044109d8c57027e62 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 11:48:32 +0800 Subject: [PATCH 04/11] update code --- quickstart/301-service-fabric-apim/main.tf | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/quickstart/301-service-fabric-apim/main.tf b/quickstart/301-service-fabric-apim/main.tf index 21fe64790..7e6f4fe7c 100644 --- a/quickstart/301-service-fabric-apim/main.tf +++ b/quickstart/301-service-fabric-apim/main.tf @@ -2,8 +2,18 @@ data "azurerm_subscription" "current" {} data "azurerm_client_config" "current" {} +terraform { + required_version = ">=0.12" + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~>2.0" + } + } +} + provider "azurerm" { - version = "=1.36.1" features {} } From 7a76b3eea1da6e8fb32906b43010cb77924c26fa Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 11:51:59 +0800 Subject: [PATCH 05/11] update code --- quickstart/301-service-fabric-apim/apim.tf | 35 +++++++++---------- quickstart/301-service-fabric-apim/azuread.tf | 10 ++---- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/quickstart/301-service-fabric-apim/apim.tf b/quickstart/301-service-fabric-apim/apim.tf index 15e9e426e..c35d09ebb 100644 --- a/quickstart/301-service-fabric-apim/apim.tf +++ b/quickstart/301-service-fabric-apim/apim.tf @@ -1,14 +1,11 @@ resource "azurerm_api_management" "default" { name = "${var.dns_prefix}-${var.name}-${var.environment}-apim" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" - publisher_name = "${var.api_publisher_name}" - publisher_email = "${var.api_publisher_email}" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name + publisher_name = var.api_publisher_name + publisher_email = var.api_publisher_email - sku { - name = "Developer" - capacity = 1 - } + sku_name = "Developer_1" # Ignore certificate changes in the future lifecycle { @@ -26,8 +23,8 @@ resource "azurerm_api_management" "default" { resource "azurerm_api_management_api" "default" { name = "demo" - resource_group_name = "${azurerm_resource_group.default.name}" - api_management_name = "${azurerm_api_management.default.name}" + resource_group_name = azurerm_resource_group.default.name + api_management_name = azurerm_api_management.default.name revision = "1" display_name = "Demo API" path = "" @@ -36,23 +33,23 @@ resource "azurerm_api_management_api" "default" { resource "azurerm_api_management_backend" "sf" { name = "service-fabric-backend" - resource_group_name = "${azurerm_resource_group.default.name}" - api_management_name = "${azurerm_api_management.default.name}" + resource_group_name = azurerm_resource_group.default.name + api_management_name = azurerm_api_management.default.name protocol = "http" url = "fabric:/fake/service" - resource_id = "${azurerm_service_fabric_cluster.default.management_endpoint}" + resource_id = azurerm_service_fabric_cluster.default.management_endpoint service_fabric_cluster { - client_certificate_thumbprint = "${azurerm_key_vault_certificate.client.thumbprint}" - server_certificate_thumbprints = ["${azurerm_key_vault_certificate.cluster.thumbprint}"] - management_endpoints = ["${azurerm_service_fabric_cluster.default.management_endpoint}"] - max_partition_resolution_retries = 3 + client_certificate_thumbprint = azurerm_key_vault_certificate.client.thumbprint + server_certificate_thumbprints = ["${azurerm_key_vault_certificate.cluster.thumbprint}"] + management_endpoints = ["${azurerm_service_fabric_cluster.default.management_endpoint}"] + max_partition_resolution_retries = 3 } } resource "azurerm_application_insights" "default" { name = "${var.name}-${var.environment}-ai" location = "West US 2" - resource_group_name = "${azurerm_resource_group.default.name}" + resource_group_name = azurerm_resource_group.default.name application_type = "web" -} \ No newline at end of file +} diff --git a/quickstart/301-service-fabric-apim/azuread.tf b/quickstart/301-service-fabric-apim/azuread.tf index 4fb11b9f9..a8b3f2c9e 100644 --- a/quickstart/301-service-fabric-apim/azuread.tf +++ b/quickstart/301-service-fabric-apim/azuread.tf @@ -7,14 +7,8 @@ resource "azuread_service_principal" "cluster" { application_id = azuread_application.cluster.application_id } -resource "random_string" "cluster_password" { - length = 32 - special = true -} - resource "azuread_service_principal_password" "cluster" { service_principal_id = azuread_service_principal.cluster.id - value = random_string.cluster_password.result end_date = "2099-01-01T01:00:00Z" } @@ -26,8 +20,8 @@ resource "random_uuid" "reader" { # Service Fabric Client resource "azuread_application" "client" { - display_name = "${var.name}-client-${var.environment}" - reply_urls = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] + display_name = "${var.name}-client-${var.environment}" + redirect_uris = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] app_role { id = random_uuid.admin.result From 99f16b14719d5bdd2e6b3d4050c58defd1021930 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 12:00:19 +0800 Subject: [PATCH 06/11] update code --- quickstart/301-service-fabric-apim/apim.tf | 3 +-- quickstart/301-service-fabric-apim/azuread.tf | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/quickstart/301-service-fabric-apim/apim.tf b/quickstart/301-service-fabric-apim/apim.tf index c35d09ebb..12d8f8a44 100644 --- a/quickstart/301-service-fabric-apim/apim.tf +++ b/quickstart/301-service-fabric-apim/apim.tf @@ -4,8 +4,7 @@ resource "azurerm_api_management" "default" { resource_group_name = azurerm_resource_group.default.name publisher_name = var.api_publisher_name publisher_email = var.api_publisher_email - - sku_name = "Developer_1" + sku_name = "Developer_1" # Ignore certificate changes in the future lifecycle { diff --git a/quickstart/301-service-fabric-apim/azuread.tf b/quickstart/301-service-fabric-apim/azuread.tf index a8b3f2c9e..7d648699f 100644 --- a/quickstart/301-service-fabric-apim/azuread.tf +++ b/quickstart/301-service-fabric-apim/azuread.tf @@ -20,8 +20,11 @@ resource "random_uuid" "reader" { # Service Fabric Client resource "azuread_application" "client" { - display_name = "${var.name}-client-${var.environment}" - redirect_uris = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] + display_name = "${var.name}-client-${var.environment}" + + web { + redirect_uris = ["https://${azurerm_public_ip.sf.fqdn}:19080/Explorer/index.html"] + } app_role { id = random_uuid.admin.result From f2f2204d2e4f99d480ed7a13568ab7ae15b25b5f Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 12:05:42 +0800 Subject: [PATCH 07/11] update code --- quickstart/301-service-fabric-apim/main.tf | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/quickstart/301-service-fabric-apim/main.tf b/quickstart/301-service-fabric-apim/main.tf index 7e6f4fe7c..228783e7d 100644 --- a/quickstart/301-service-fabric-apim/main.tf +++ b/quickstart/301-service-fabric-apim/main.tf @@ -2,22 +2,11 @@ data "azurerm_subscription" "current" {} data "azurerm_client_config" "current" {} -terraform { - required_version = ">=0.12" - - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "~>2.0" - } - } -} - provider "azurerm" { - features {} + version = "=1.36.1" } resource "azurerm_resource_group" "default" { name = "${var.name}-${var.environment}-rg" - location = var.location -} + location = "${var.location}" +} \ No newline at end of file From 5da2d394736444136791dfc133a75987bd93e217 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 12:06:31 +0800 Subject: [PATCH 08/11] update code --- quickstart/301-service-fabric-apim/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/301-service-fabric-apim/main.tf b/quickstart/301-service-fabric-apim/main.tf index 228783e7d..66ff3720b 100644 --- a/quickstart/301-service-fabric-apim/main.tf +++ b/quickstart/301-service-fabric-apim/main.tf @@ -9,4 +9,4 @@ provider "azurerm" { resource "azurerm_resource_group" "default" { name = "${var.name}-${var.environment}-rg" location = "${var.location}" -} \ No newline at end of file +} From feb35dedcb52e07d4571415378b2801a8326daff Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 15 Nov 2023 14:01:23 +0800 Subject: [PATCH 09/11] update code --- .../301-service-fabric-apim/keyvault.tf | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/quickstart/301-service-fabric-apim/keyvault.tf b/quickstart/301-service-fabric-apim/keyvault.tf index 36a78f312..fc1b7d543 100644 --- a/quickstart/301-service-fabric-apim/keyvault.tf +++ b/quickstart/301-service-fabric-apim/keyvault.tf @@ -1,67 +1,67 @@ resource "azurerm_key_vault" "cluster" { - name = "${var.dns_prefix}-${substr(var.name,0,12)}-${var.environment_short}-kv" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" - tenant_id = "${data.azurerm_client_config.current.tenant_id}" + name = "${var.dns_prefix}-${substr(var.name, 0, 12)}-${var.environment_short}-kv" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name + tenant_id = data.azurerm_client_config.current.tenant_id enabled_for_deployment = true enabled_for_disk_encryption = true enabled_for_template_deployment = true sku_name = "standard" access_policy { - tenant_id = "${data.azurerm_subscription.current.tenant_id}" - object_id = "${var.client_object_id}" + tenant_id = data.azurerm_subscription.current.tenant_id + object_id = var.client_object_id certificate_permissions = [ - "create", - "delete", - "deleteissuers", - "get", - "getissuers", - "import", - "list", - "listissuers", - "managecontacts", - "manageissuers", - "setissuers", - "update", + "Create", + "Delete", + "DeleteIssuers", + "Get", + "GetIssuers", + "Import", + "List", + "ListIssuers", + "ManageContacts", + "ManageIssuers", + "SetIssuers", + "Update", ] key_permissions = [ - "backup", - "create", - "decrypt", - "delete", - "encrypt", - "get", - "import", - "list", - "purge", - "recover", - "restore", - "sign", - "unwrapKey", - "update", - "verify", - "wrapKey", + "Backup", + "Create", + "Decrypt", + "Delete", + "Encrypt", + "Get", + "Import", + "List", + "Purge", + "Recover", + "Restore", + "Sign", + "UnwrapKey", + "Update", + "Verify", + "WrapKey", ] secret_permissions = [ - "backup", - "delete", - "get", - "list", - "purge", - "recover", - "restore", - "set", + "Backup", + "Delete", + "Get", + "List", + "Purge", + "Recover", + "Restore", + "Set", ] } } resource "azurerm_key_vault_certificate" "cluster" { name = "service-fabric-cluster" - key_vault_id = "${azurerm_key_vault.cluster.id}" + key_vault_id = azurerm_key_vault.cluster.id certificate_policy { issuer_parameters { @@ -115,7 +115,7 @@ resource "azurerm_key_vault_certificate" "cluster" { resource "azurerm_key_vault_certificate" "client" { name = "service-fabric-client" - key_vault_id = "${azurerm_key_vault.cluster.id}" + key_vault_id = azurerm_key_vault.cluster.id certificate_policy { issuer_parameters { From 1efb02be6d784710931a727c0a261de44d06843b Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Jan 2024 13:54:18 +0800 Subject: [PATCH 10/11] update code --- .../301-service-fabric-apim/keyvault.tf | 2 +- quickstart/301-service-fabric-apim/main.tf | 9 ++- quickstart/301-service-fabric-apim/network.tf | 64 +++++++++---------- .../301-service-fabric-apim/service_fabric.tf | 30 ++++----- quickstart/301-service-fabric-apim/vmss.tf | 24 +++---- 5 files changed, 68 insertions(+), 61 deletions(-) diff --git a/quickstart/301-service-fabric-apim/keyvault.tf b/quickstart/301-service-fabric-apim/keyvault.tf index fc1b7d543..838c04071 100644 --- a/quickstart/301-service-fabric-apim/keyvault.tf +++ b/quickstart/301-service-fabric-apim/keyvault.tf @@ -1,5 +1,5 @@ resource "azurerm_key_vault" "cluster" { - name = "${var.dns_prefix}-${substr(var.name, 0, 12)}-${var.environment_short}-kv" + name = "${random_string.name_suffix.result}-kv" location = azurerm_resource_group.default.location resource_group_name = azurerm_resource_group.default.name tenant_id = data.azurerm_client_config.current.tenant_id diff --git a/quickstart/301-service-fabric-apim/main.tf b/quickstart/301-service-fabric-apim/main.tf index 66ff3720b..11c06b9c8 100644 --- a/quickstart/301-service-fabric-apim/main.tf +++ b/quickstart/301-service-fabric-apim/main.tf @@ -8,5 +8,12 @@ provider "azurerm" { resource "azurerm_resource_group" "default" { name = "${var.name}-${var.environment}-rg" - location = "${var.location}" + location = var.location +} + +resource "random_string" "name_suffix" { + length = 8 + lower = true + upper = true + special = false } diff --git a/quickstart/301-service-fabric-apim/network.tf b/quickstart/301-service-fabric-apim/network.tf index 93ea4350e..5b0773c8d 100644 --- a/quickstart/301-service-fabric-apim/network.tf +++ b/quickstart/301-service-fabric-apim/network.tf @@ -5,96 +5,96 @@ locals { resource "azurerm_virtual_network" "default" { name = "${var.name}-vnet" address_space = ["10.0.0.0/16"] - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name } resource "azurerm_subnet" "default" { name = "${var.name}-default-subnet" - resource_group_name = "${azurerm_resource_group.default.name}" - virtual_network_name = "${azurerm_virtual_network.default.name}" + resource_group_name = azurerm_resource_group.default.name + virtual_network_name = azurerm_virtual_network.default.name address_prefix = "10.0.0.0/24" } resource "azurerm_subnet" "sf" { name = "${var.name}-sf-subnet" - resource_group_name = "${azurerm_resource_group.default.name}" - virtual_network_name = "${azurerm_virtual_network.default.name}" + resource_group_name = azurerm_resource_group.default.name + virtual_network_name = azurerm_virtual_network.default.name address_prefix = "10.0.1.0/24" } resource "azurerm_public_ip" "sf" { - name = "${var.name}-pip" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" + name = "${var.name}-${random_string.name_suffix.result}-pip" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name allocation_method = "Dynamic" domain_name_label = "${var.dns_prefix}-${var.name}-${var.environment_short}-sf" } resource "azurerm_lb" "sf" { name = "${var.name}-lb" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name frontend_ip_configuration { - name = "${local.feip_config_name}" - public_ip_address_id = "${azurerm_public_ip.sf.id}" + name = local.feip_config_name + public_ip_address_id = azurerm_public_ip.sf.id } } resource "azurerm_lb_nat_pool" "sf" { name = "${var.name}-nat-pool" - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id count = "1" protocol = "Tcp" frontend_port_start = 3389 frontend_port_end = 4500 backend_port = 3389 - frontend_ip_configuration_name = "${local.feip_config_name}" + frontend_ip_configuration_name = local.feip_config_name } resource "azurerm_lb_backend_address_pool" "sf" { - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id name = "ServiceFabricAddressPool" } # Probes resource "azurerm_lb_probe" "fabric_gateway" { - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id name = "${var.name}-probe-19000" port = 19000 } resource "azurerm_lb_probe" "http" { - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id name = "${var.name}-probe-19080" port = 19080 } resource "azurerm_lb_rule" "http" { - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" - backend_address_pool_id = "${azurerm_lb_backend_address_pool.sf.id}" - probe_id = "${azurerm_lb_probe.http.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id + backend_address_pool_id = azurerm_lb_backend_address_pool.sf.id + probe_id = azurerm_lb_probe.http.id name = "http" protocol = "Tcp" frontend_port = 19080 backend_port = 19080 - frontend_ip_configuration_name = "${local.feip_config_name}" + frontend_ip_configuration_name = local.feip_config_name } resource "azurerm_lb_rule" "fabric_gateway" { - resource_group_name = "${azurerm_resource_group.default.name}" - loadbalancer_id = "${azurerm_lb.sf.id}" - backend_address_pool_id = "${azurerm_lb_backend_address_pool.sf.id}" - probe_id = "${azurerm_lb_probe.fabric_gateway.id}" + resource_group_name = azurerm_resource_group.default.name + loadbalancer_id = azurerm_lb.sf.id + backend_address_pool_id = azurerm_lb_backend_address_pool.sf.id + probe_id = azurerm_lb_probe.fabric_gateway.id name = "fabric_gateway" protocol = "Tcp" frontend_port = 19000 backend_port = 19000 - frontend_ip_configuration_name = "${local.feip_config_name}" + frontend_ip_configuration_name = local.feip_config_name } diff --git a/quickstart/301-service-fabric-apim/service_fabric.tf b/quickstart/301-service-fabric-apim/service_fabric.tf index affb76b9a..36505b1eb 100644 --- a/quickstart/301-service-fabric-apim/service_fabric.tf +++ b/quickstart/301-service-fabric-apim/service_fabric.tf @@ -1,15 +1,15 @@ resource "azurerm_storage_account" "sf" { - name = "${var.dns_prefix}${substr(replace(var.name, "-", ""), 0, 16)}sf${var.environment_short}" - resource_group_name = "${azurerm_resource_group.default.name}" - location = "${azurerm_resource_group.default.location}" + name = "${random_string.name_suffix.result}sf" + resource_group_name = azurerm_resource_group.default.name + location = azurerm_resource_group.default.location account_tier = "Standard" account_replication_type = "LRS" } resource "azurerm_service_fabric_cluster" "default" { name = "${var.name}-sf" - resource_group_name = "${azurerm_resource_group.default.name}" - location = "${azurerm_resource_group.default.location}" + resource_group_name = azurerm_resource_group.default.name + location = azurerm_resource_group.default.location reliability_level = "Bronze" vm_image = "Windows" management_endpoint = "https://${azurerm_public_ip.sf.fqdn}:19080" @@ -36,9 +36,9 @@ resource "azurerm_service_fabric_cluster" "default" { } azure_active_directory { - tenant_id = "${data.azurerm_subscription.current.tenant_id}" - cluster_application_id = "${azuread_application.client.application_id}" - client_application_id = "${azuread_application.cluster.application_id}" + tenant_id = data.azurerm_subscription.current.tenant_id + cluster_application_id = azuread_application.client.application_id + client_application_id = azuread_application.cluster.application_id } fabric_settings { @@ -58,21 +58,21 @@ resource "azurerm_service_fabric_cluster" "default" { } certificate { - thumbprint = "${azurerm_key_vault_certificate.cluster.thumbprint}" - thumbprint_secondary = "${azurerm_key_vault_certificate.cluster.thumbprint}" + thumbprint = azurerm_key_vault_certificate.cluster.thumbprint + thumbprint_secondary = azurerm_key_vault_certificate.cluster.thumbprint x509_store_name = "My" } client_certificate_thumbprint { - thumbprint = "${azurerm_key_vault_certificate.client.thumbprint}" + thumbprint = azurerm_key_vault_certificate.client.thumbprint is_admin = true } diagnostics_config { - storage_account_name = "${azurerm_storage_account.sf.name}" + storage_account_name = azurerm_storage_account.sf.name protected_account_key_name = "StorageAccountKey1" - blob_endpoint = "${azurerm_storage_account.sf.primary_blob_endpoint}" - queue_endpoint = "${azurerm_storage_account.sf.primary_queue_endpoint}" - table_endpoint = "${azurerm_storage_account.sf.primary_table_endpoint}" + blob_endpoint = azurerm_storage_account.sf.primary_blob_endpoint + queue_endpoint = azurerm_storage_account.sf.primary_queue_endpoint + table_endpoint = azurerm_storage_account.sf.primary_table_endpoint } } diff --git a/quickstart/301-service-fabric-apim/vmss.tf b/quickstart/301-service-fabric-apim/vmss.tf index c20134fef..e959578ae 100644 --- a/quickstart/301-service-fabric-apim/vmss.tf +++ b/quickstart/301-service-fabric-apim/vmss.tf @@ -1,7 +1,7 @@ resource "azurerm_storage_account" "vmss" { - name = "${var.dns_prefix}${substr(replace(var.name, "-", ""), 0, 12)}vmss${var.environment_short}" - resource_group_name = "${azurerm_resource_group.default.name}" - location = "${azurerm_resource_group.default.location}" + name = "${random_string.name_suffix.result}vmss" + resource_group_name = azurerm_resource_group.default.name + location = azurerm_resource_group.default.location account_tier = "Standard" account_replication_type = "LRS" } @@ -9,15 +9,15 @@ resource "azurerm_storage_account" "vmss" { # Vm Scale Set resource "azurerm_virtual_machine_scale_set" "default" { name = "${var.name}-vmss" - location = "${azurerm_resource_group.default.location}" - resource_group_name = "${azurerm_resource_group.default.name}" + location = azurerm_resource_group.default.location + resource_group_name = azurerm_resource_group.default.name upgrade_policy_mode = "Automatic" overprovision = false sku { name = "Standard_D1_v2" tier = "Standard" - capacity = "${var.cluster_size}" + capacity = var.cluster_size } storage_profile_image_reference { @@ -43,12 +43,12 @@ resource "azurerm_virtual_machine_scale_set" "default" { os_profile { computer_name_prefix = "sfvm" - admin_username = "${var.admin_username}" - admin_password = "${var.admin_password}" + admin_username = var.admin_username + admin_password = var.admin_password } os_profile_secrets { - source_vault_id = "${azurerm_key_vault.cluster.id}" + source_vault_id = azurerm_key_vault.cluster.id vault_certificates { certificate_url = "${azurerm_key_vault.cluster.vault_uri}secrets/${azurerm_key_vault_certificate.cluster.name}/${azurerm_key_vault_certificate.cluster.version}" @@ -63,8 +63,8 @@ resource "azurerm_virtual_machine_scale_set" "default" { } boot_diagnostics { - enabled = true - storage_uri = "${azurerm_storage_account.vmss.primary_blob_endpoint}" + enabled = true + storage_uri = azurerm_storage_account.vmss.primary_blob_endpoint } network_profile { @@ -74,7 +74,7 @@ resource "azurerm_virtual_machine_scale_set" "default" { ip_configuration { primary = true name = "IPConfiguration" - subnet_id = "${azurerm_subnet.sf.id}" + subnet_id = azurerm_subnet.sf.id load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.sf.id}"] load_balancer_inbound_nat_rules_ids = ["${azurerm_lb_nat_pool.sf[0].id}"] } From 5bd06f3ea64fc6e012065b544254f1817b5ea0dc Mon Sep 17 00:00:00 2001 From: hezijie Date: Fri, 5 Jan 2024 14:24:40 +0800 Subject: [PATCH 11/11] try to fix example --- test/e2e/quickstart_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/e2e/quickstart_test.go b/test/e2e/quickstart_test.go index 54ad12376..665c7bdaa 100644 --- a/test/e2e/quickstart_test.go +++ b/test/e2e/quickstart_test.go @@ -20,6 +20,7 @@ var speicalTests = map[string]func(*testing.T){ "quickstart/101-virtual-network-manager-create-management-group-scope": test101VirtualNetworkManagerCreateManagementGroupScope, "quickstart/201-vmss-packer-jumpbox": test201VmssPackerJumpbox, "quickstart/202-machine-learning-moderately-secure-existing-VNet": test202machineLearningModeratelySecureExistingVnet, + "quickstart/301-service-fabric-apim": test301ServiceFabricApim, } func Test_Quickstarts(t *testing.T) { @@ -196,6 +197,19 @@ func test202machineLearningModeratelySecureExistingVnet(t *testing.T) { }) } +func test301ServiceFabricApim(t *testing.T) { + rootPath := filepath.Join("..", "..") + examplePath := filepath.Join("quickstart", "301-service-fabric-apim") + vars := map[string]any{} + if msiId := os.Getenv("MSI_ID"); msiId != "" { + vars["client_object_id"] = msiId + } + + helper.RunE2ETest(t, rootPath, examplePath, terraform.Options{ + Vars: vars, + }, nil) +} + func removeDuplicates(s []string) []string { m := make(map[string]struct{}) result := []string{}