Skip to content

Instantly share code, notes, and snippets.

@jesseloudon
Created November 9, 2020 23:52
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 jesseloudon/6ddf5496ad1b85cdb4b90d81775ea9dc to your computer and use it in GitHub Desktop.
Save jesseloudon/6ddf5496ad1b85cdb4b90d81775ea9dc to your computer and use it in GitHub Desktop.
ansible on azure part 2
variable "nsgName" {
type = string
description = "network security group name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "nsgRule1" {
type = map
description = "network security group rule 1 - remember to modify 'source_address_prefix' with your own local Public IP address https://www.whatismyip.com/"
default = {
"name" = "SSH_allow"
"description" = "Allow inbound SSH from single Public IP to Ansible Host"
"priority" = 100
"direction" = "Inbound"
"access" = "Allow"
"protocol" = "Tcp"
"source_port_range" = "*"
"destination_port_range" = "22"
"source_address_prefix" = "0.0.0.0" #Update with your own public IP address https://www.whatismyip.com/
"destination_address_prefix" = "10.0.0.5"
}
}
resource "azurerm_network_security_group" "subnet1nsg1" {
name = var.nsgName
location = azurerm_resource_group.rg1.location
resource_group_name = azurerm_resource_group.rg1.name
}
resource "azurerm_network_security_rule" "subnet1nsg1rule1" {
name = var.nsgRule1["name"]
description = var.nsgRule1["description"]
priority = var.nsgRule1["priority"]
direction = var.nsgRule1["direction"]
access = var.nsgRule1["access"]
protocol = var.nsgRule1["protocol"]
source_port_range = var.nsgRule1["source_port_range"]
destination_port_range = var.nsgRule1["destination_port_range"]
source_address_prefix = var.nsgRule1["source_address_prefix"]
destination_address_prefix = var.nsgRule1["destination_address_prefix"]
resource_group_name = azurerm_resource_group.rg1.name
network_security_group_name = azurerm_network_security_group.subnet1nsg1.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment