zot24
8/4/2016 - 7:01 PM

terraform_config_file_issue

provider "azurerm" {}

#########
# group #
#########

module "resource_group" {
    source = "github.com/zot24/tf_azure_resource_group"

    name = "${var.app_name}_${var.resource_group_name}"
    location = "${var.location}"
}

############
# security #
############

module "network_security_group" {
    source = "github.com/zot24/tf_azure_network_security_group"

    name = "${var.app_name}_${var.security_group_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
}

module "sr_web" {
    source = "github.com/zot24/tf_azure_network_security_rules//sr_web"

    priority = "${var.sr_web_priority}"
    resource_group_name = "${module.resource_group.name}"
    network_security_group_name = "${module.network_security_group.name}"
}

module "sr_registry" {
    source = "github.com/zot24/tf_azure_network_security_rules//sr_registry"

    priority = "${var.sr_registry_priority}"
    resource_group_name = "${module.resource_group.name}"
    network_security_group_name = "${module.network_security_group.name}"
}

###########
# network #
###########

module "virtual_network" {
    source = "github.com/zot24/tf_azure_virtual_network"

    name = "${var.app_name}_${var.virtual_network_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
    address_space =  "${var.address_space}"
}

module "subnet" {
    source = "github.com/zot24/tf_azure_subnet"

    name = "${var.app_name}_${var.subnet_name}"
    resource_group_name = "${module.resource_group.name}"
    virtual_network_name = "${module.virtual_network.name}"
    network_security_group_id = "${module.network_security_group.id}"
    address_prefix = "${var.address_prefix}"
}

module "public_ip" {
    source = "github.com/zot24/tf_azure_public_ip"

    name = "${var.app_name}_${var.public_ip_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
    public_ip_allocation = "${var.public_ip_allocation}"
}

module "network_interface" {
    source = "github.com/zot24/tf_azure_network_interface"

    name = "${var.app_name}_${var.network_interface_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
    network_security_group_id = "${module.network_security_group.id}"

    ip_configuration_name = "${var.app_name}_${var.ip_configuration_name}"
    ip_configuration_subnet_id = "${module.subnet.id}"
    ip_private_allocation = "${var.ip_private_allocation}"
    ip_public_id = "${module.public_ip.id}"
}

resource "null_resource" "ansible_hosts" {
    provisioner "local-exec" {
        command = "echo '[${var.app_name}]\\n${module.public_ip.ip_address}' > ../ansible/hosts"
    }
}

###########
# storage #
###########

module "storage_account" {
    source = "github.com/zot24/tf_azure_storage_account"

    name = "${var.app_name}${var.storage_account_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
    account_type = "${var.account_type}"
}

module "storage_container" {
    source = "github.com/zot24/tf_azure_storage_container"

    name = "${var.app_name}${var.storage_container_name}"
    resource_group_name = "${module.resource_group.name}"
    storage_account_name = "${module.storage_account.name}"
    container_access_type = "${var.container_access_type}"
}

module "storage_blob" {
    source = "github.com/zot24/tf_azure_storage_blob"

    name = "${var.app_name}-${var.storage_blob_name}"
    resource_group_name = "${module.resource_group.name}"
    storage_account_name = "${module.storage_account.name}"
    storage_container_name = "${module.storage_container.name}"
    size = "${var.size}"
}

###################
# virtual machine #
###################

module "virtual_machine" {
    source = "github.com/zot24/tf_azure_virtual_machine//with_data_disk"

    name = "${var.app_name}_${var.vm_name}"
    location = "${var.location}"
    resource_group_name = "${module.resource_group.name}"
    network_interface_ids = "${module.network_interface.id}"
    vm_size = "${var.vm_size}"

    image_publisher = "${var.image_publisher}"
    image_offer = "${var.image_offer}"
    image_sku = "${var.image_sku}"
    image_version = "${var.image_version}"

    os_disk_name = "${var.app_name}_${var.os_disk_name}"
    os_disk_vhd_uri = "${module.storage_account.primary_blob_endpoint}${module.storage_container.name}/${var.app_name}-${var.os_disk_vhd_uri_name}.vhd"
    os_disk_caching = "${var.os_disk_caching}"
    os_disk_create_option = "${var.os_disk_create_option}"

    data_disk_name = "${var.app_name}_${var.data_disk_name}"
    data_disk_vhd_uri = "${module.storage_account.primary_blob_endpoint}${module.storage_container.name}/${module.storage_blob.name}"
    data_disk_create_option = "${var.data_disk_create_option}"
    data_disk_size_gb = "${var.data_disk_size_gb}"
    data_disk_lun = "${var.data_disk_lun}"

    os_profile_computer_name = "${var.os_profile_computer_name}"
    os_profile_username = "${var.os_profile_username}"
    os_profile_password = "${var.os_profile_password}"

    disable_password_authentication = "${var.disable_password_authentication}"
    ssh_keys_path = "/home/${var.os_profile_username}/.ssh/authorized_keys"
    ssh_keys_key_data = "${file("${var.ssh_keys_key_data_path}")}"
}