Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Jan 5, 2024
1 parent 1f9606f commit 1efb02b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 61 deletions.
2 changes: 1 addition & 1 deletion quickstart/301-service-fabric-apim/keyvault.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 8 additions & 1 deletion quickstart/301-service-fabric-apim/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
64 changes: 32 additions & 32 deletions quickstart/301-service-fabric-apim/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
30 changes: 15 additions & 15 deletions quickstart/301-service-fabric-apim/service_fabric.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 {
Expand All @@ -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
}
}
24 changes: 12 additions & 12 deletions quickstart/301-service-fabric-apim/vmss.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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"
}

# 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 {
Expand All @@ -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}"
Expand All @@ -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 {
Expand All @@ -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}"]
}
Expand Down

0 comments on commit 1efb02b

Please sign in to comment.