Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 301-service-fabric #294

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions quickstart/301-service-fabric/azuread.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -13,35 +13,47 @@ 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
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}"

web {
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"
}

Expand All @@ -57,7 +69,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" {
Expand All @@ -66,7 +78,6 @@ 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
end_date = "2099-01-01T01:00:00Z"
}
94 changes: 50 additions & 44 deletions quickstart/301-service-fabric/keyvault.tf
Original file line number Diff line number Diff line change
@@ -1,67 +1,73 @@
resource "random_string" "kv_name_prefix" {
length = 21
special = false
numeric = false
}

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 = "${random_string.kv_name_prefix.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
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 {
Expand Down Expand Up @@ -115,7 +121,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 {
Expand Down
70 changes: 38 additions & 32 deletions quickstart/301-service-fabric/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,96 +5,102 @@ 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 "random_string" "pip_name_prefix" {
length = 17
special = false
numeric = false
}

resource "azurerm_public_ip" "sf" {
name = "${var.name}-pip"
location = "${azurerm_resource_group.default.location}"
resource_group_name = "${azurerm_resource_group.default.name}"
name = "${random_string.pip_name_prefix.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
}
Loading
Loading