Created
June 18, 2019 09:14
-
-
Save kikitux/bd48b6eb199f25b7a2a13fddc4ef8ab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# variables | |
variable "environment" { | |
default = "eastus" | |
} | |
variable "location" { | |
default = "eastus" | |
} | |
variable "prefix" { | |
default = "alvaro" | |
} | |
variable "ARM_SUBSCRIPTION_ID" { | |
description = "The Azure subscription ID" | |
} | |
variable "ARM_CLIENT_ID" { | |
description = "The Azure client ID" | |
} | |
variable "ARM_CLIENT_SECRET" { | |
description = "The Azure secret access key" | |
} | |
variable "ARM_TENANT_ID" { | |
description = "The Azure tenant ID" | |
} | |
# Configure the Microsoft Azure Provider | |
provider "azurerm" { | |
subscription_id = "${var.ARM_SUBSCRIPTION_ID}" | |
client_id = "${var.ARM_CLIENT_ID}" | |
client_secret = "${var.ARM_CLIENT_SECRET}" | |
tenant_id = "${var.ARM_TENANT_ID}" | |
} | |
# Application Gateway public IP | |
resource "azurerm_public_ip" "ag_pubip" { | |
name = "${var.environment}-AG-PublicIP" | |
location = "${var.location}" | |
resource_group_name = "${azurerm_resource_group.rg.name}" | |
allocation_method = "Dynamic" | |
sku = "Basic" | |
domain_name_label = "${lower(var.environment)}-control" | |
} | |
data "azurerm_public_ip" "ag_pubip" { | |
name = "${azurerm_public_ip.ag_pubip.name}" | |
resource_group_name = "${azurerm_resource_group.rg.name}" | |
} | |
output "data_ag_pubip" { | |
value = "${data.azurerm_public_ip.ag_pubip.ip_address}" | |
} | |
# Create a resource group if it does not exist | |
resource "azurerm_resource_group" "rg" { | |
name = "${var.prefix}ResourceGroup" | |
location = "${var.location}" | |
tags { | |
environment = "${var.prefix} Terraform Demo" | |
} | |
} | |
resource "azurerm_lb" "test" { | |
name = "TestLoadBalancer" | |
location = "${var.location}" | |
resource_group_name = "${azurerm_resource_group.rg.name}" | |
frontend_ip_configuration { | |
name = "PublicIPAddress" | |
public_ip_address_id = "${azurerm_public_ip.ag_pubip.id}" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment