Skip to content

Instantly share code, notes, and snippets.

@HighwayofLife
Created June 9, 2017 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HighwayofLife/5ef991b176b42348808072d28a292724 to your computer and use it in GitHub Desktop.
Save HighwayofLife/5ef991b176b42348808072d28a292724 to your computer and use it in GitHub Desktop.
Passing Storage Account Endpoints to ARM Templates
variable "resourceGroupName" {
default = "myResourceGroup"
}
variable "location" {
default = "West US"
}
variable "clusterName" {
default = "servicefabcluster"
}
variable "nodeCount" {
default = 5
}
variable "storageAccountPrefix" {
default = "suplog"
}
resource "azurerm_resource_group" "main" {
name = "${var.resourceGroupName}"
location = "${var.location}"
}
# Storage account name must be globally unique, generate a random id
resource "random_id" "supportlog" {
keepers = {
name = "supportlog"
}
byte_length = 12
}
# Example creating a single storage account
resource "azurerm_storage_account" "supportlog" {
name = "${format("%.24s", lower("${var.storageAccountPrefix}${random_id.supportlog.id}"))}"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${var.location}"
account_type = "Standard_GRS"
}
# Create a service fabric cluster using the module
module "service_fabric_cluster" {
source = "terraform-modules/azure_service_fabric_cluster"
resource_group_name = "${azurerm_resource_group.main.name}"
cluster_location = "${var.location}"
cluster_name = "${var.clusterName}"
load_balancer_ip_fqdn = "${azurerm_lb.lb.private_ip_address}"
node_count = "${var.nodeCount}"
node_type_name = "ntype0"
support_log_storage_account_name = "${azurerm_storage_account.supportlog.name}"
support_log_storage_account_blob_endpoint = "${azurerm_storage_account.supportlog.primary_blob_endpoint}"
support_log_storage_account_table_endpoint = "${azurerm_storage_account.supportlog.primary_table_endpoint}"
support_log_storage_account_queue_endpoint = "${azurerm_storage_account.supportlog.primary_queue_endpoint}"
}
#####################################################
############# Terraform Module Snippet ##############
#####################################################
resource "azurerm_template_deployment" "servicefabric" {
name = "${var.cluster_name}"
resource_group_name = "${var.resource_group_name}"
deployment_mode = "Incremental"
template_body = "${file("terraform-modules/azure_service_fabric_cluster/service_fabric_template.json")}"
# These parameters would be defined in the service_fabric_template.json ARM template
parameters {
application_end_port = "${var.application_end_port}"
application_start_port = "${var.application_start_port}"
cluster_location = "${var.cluster_location}"
cluster_name = "${var.cluster_name}"
ephemeral_end_port = "${var.ephemeral_end_port}"
ephemeral_start_port = "${var.ephemeral_start_port}"
fabric_http_gateway_port = "${var.fabric_http_gateway_port}"
fabric_tcp_gateway_port = "${var.fabric_tcp_gateway_port}"
load_balancer_ip_fqdn = "${var.load_balancer_ip_fqdn}"
node_count = "${var.node_count}"
node_type_name = "${var.node_type_name}"
support_log_storage_account_name = "${var.support_log_storage_account_name}"
support_log_storage_account_blob_endpoint = "${var.support_log_storage_account_blob_endpoint}"
support_log_storage_account_table_endpoint = "${var.support_log_storage_account_table_endpoint}"
support_log_storage_account_queue_endpoint = "${var.support_log_storage_account_queue_endpoint}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment