-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
31 lines (26 loc) · 1.73 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
terraform {
# The configuration for this backend will be filled in by Terragrunt
backend "azurerm" {}
}
provider "azurerm" {}
resource "azurerm_network_security_group" "security_group" {
name = "sg-${var.name}"
location = "${var.location}"
resource_group_name = "${var.rg_name}"
tags = "${var.tags}"
}
resource "azurerm_network_security_rule" "security_rules" {
count = "${length(var.security_rules)}"
name = "sr-${lookup(var.security_rules[count.index], "name", "default_rule_name")}"
priority = "${lookup(var.security_rules[count.index], "priority", "200")}"
direction = "${lookup(var.security_rules[count.index], "direction", "Any")}"
access = "${lookup(var.security_rules[count.index], "access", "Allow")}"
protocol = "${lookup(var.security_rules[count.index], "protocol", "*")}"
source_port_ranges = ["${split(",", "${lookup(var.security_rules[count.index], "source_port_range", "*" )}" )}"]
destination_port_ranges = ["${split(",", "${lookup(var.security_rules[count.index], "destination_port_range", "*" )}" )}"]
source_address_prefix = "${lookup(var.security_rules[count.index], "source_address_prefix", "*")}"
destination_address_prefix = "${lookup(var.security_rules[count.index], "destination_address_prefix", "*")}"
description = "${lookup(var.security_rules[count.index], "description", "Security rule for ${lookup(var.security_rules[count.index], "name", "default_rule_name")}")}"
resource_group_name = "${var.rg_name}"
network_security_group_name = "${azurerm_network_security_group.security_group.name}"
}