Skip to content

Instantly share code, notes, and snippets.

@tombuildsstuff
Created June 14, 2017 17:52
Show Gist options
  • Save tombuildsstuff/109f6794f85cd289e2003dc9390f2df1 to your computer and use it in GitHub Desktop.
Save tombuildsstuff/109f6794f85cd289e2003dc9390f2df1 to your computer and use it in GitHub Desktop.
resource "azurerm_resource_group" "test" {
name = "bug-test21"
location = "West Europe"
}
resource "azurerm_virtual_network" "vnet" {
name = "mynetwork"
resource_group_name = "${azurerm_resource_group.test.name}"
address_space = ["10.0.0.0/8"]
location = "${azurerm_resource_group.test.location}"
}
resource "azurerm_subnet" "subnet" {
name = "mynetwork"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
address_prefix = "10.0.0.0/11"
}
resource "azurerm_resource_group" "test" {
name = "bug-dev7986"
location = "West Europe"
}
resource "azurerm_network_security_group" "test" {
name = "bug-dev7986nsg"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
security_rule {
name = "test123"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}
tags {
environment = "Production"
}
}
resource "azurerm_network_security_rule" "test" {
name = "bug-dev7986nsr"
priority = 100
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.test.name}"
network_security_group_name = "${azurerm_network_security_group.test.name}"
}
resource "azurerm_public_ip" "test" {
name = "bug-dev7986pip"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Dynamic"
tags {
environment = "Production"
}
}
resource "azurerm_virtual_network" "test" {
name = "bugdev7986nw"
address_space = ["10.0.0.0/16"]
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
subnet {
name = "bugdev7986sn2"
address_prefix = "10.0.3.0/24"
security_group = "${azurerm_network_security_group.test.id}"
}
}
resource "azurerm_subnet" "first" {
name = "bugdev7986sn1"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_subnet" "second" {
name = "bugdev7986sn3"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.4.0/24"
}
resource "azurerm_network_interface" "test1" {
name = "bugdev7986ni1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.first.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
resource "azurerm_network_interface" "test2" {
name = "bugdev7986ni2"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.first.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
resource "azurerm_network_interface" "test3" {
name = "bugdev7986ni3"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.second.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
resource "azurerm_network_interface" "test4" {
name = "bugdev7986ni4"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.second.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
resource "azurerm_resource_group" "test" {
name = "bug-dev7986"
location = "West Europe"
}
resource "azurerm_virtual_network" "test" {
name = "bugdev7986nw"
address_space = ["10.0.0.0/16"]
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
}
resource "azurerm_subnet" "first" {
name = "bugdev7986sn1"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_subnet" "second" {
name = "bugdev7986sn3"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.4.0/24"
}
resource "azurerm_subnet" "third" {
name = "bugdev7986sn2"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.3.0/24"
}
resource "azurerm_network_interface" "first" {
name = "bugdev7986ni1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.first.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
resource "azurerm_network_interface" "second" {
name = "bugdev7986ni3"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.second.id}"
private_ip_address_allocation = "dynamic"
}
tags {
environment = "staging"
}
}
variable "prefix" {
default = "bug-test3"
}
resource "azurerm_resource_group" "test" {
name = "${var.prefix}-rg"
location = "West Europe"
}
resource "azurerm_virtual_network" "test" {
name = "${var.prefix}-vn"
address_space = ["10.0.0.0/16"]
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
# First
resource "azurerm_route_table" "first" {
name = "${var.prefix}-private-1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_route" "first" {
name = "${var.prefix}-private-1"
resource_group_name = "${azurerm_resource_group.test.name}"
route_table_name = "${azurerm_route_table.first.name}"
address_prefix = "0.0.0.0/0"
next_hop_type = "None"
}
resource "azurerm_subnet" "first" {
name = "${var.prefix}-private-1"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.0.0/24"
route_table_id = "${azurerm_route_table.first.id}"
}
# Second
resource "azurerm_route_table" "second" {
name = "${var.prefix}-private-2"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_route" "second" {
name = "${var.prefix}-private-2"
resource_group_name = "${azurerm_resource_group.test.name}"
route_table_name = "${azurerm_route_table.second.name}"
address_prefix = "0.0.0.0/0"
next_hop_type = "None"
}
resource "azurerm_subnet" "second" {
name = "${var.prefix}-private-1"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.1.0/24"
route_table_id = "${azurerm_route_table.second.id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment