Skip to content

Instantly share code, notes, and snippets.

@migara
Created August 25, 2022 17:00
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 migara/87bf79dd5e6b1316cf033bcb8308f8a7 to your computer and use it in GitHub Desktop.
Save migara/87bf79dd5e6b1316cf033bcb8308f8a7 to your computer and use it in GitHub Desktop.
provider "aws" {
region = "us-east-1"
}
module "vmseries-vpc" {
source = "PaloAltoNetworks/vmseries-modules/aws//modules/vpc"
version = "0.2.2"
name = "vpc-example"
create_vpc = false
security_groups = {
vmseries_mgmt = {
name = "vmseries_mgmt"
rules = {
all_outbound = {
description = "Permit All traffic outbound"
type = "egress", from_port = "0", to_port = "0", protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
https = {
description = "Permit HTTPS"
type = "ingress", from_port = "443", to_port = "443", protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # TODO: update here
}
ssh = {
description = "Permit SSH"
type = "ingress", from_port = "22", to_port = "22", protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # TODO: update here
}
}
}
vmseries_private = {
name = "vmseries_private"
rules = {}
}
}
global_tags = {
ManagedBy = "Terraform"
Application = "Advanced Demo"
Component = "New"
}
}
variable "subnets" {
default = {
"10.100.0.0/24" = { az = "us-east-1a", set = "mgmt" }
"10.100.64.0/24" = { az = "us-east-1b", set = "mgmt" }
"10.100.2.0/24" = { az = "us-east-1a", set = "private" }
"10.100.66.0/24" = { az = "us-east-1b", set = "private" }
}
}
module "subnet_sets" {
source = "PaloAltoNetworks/vmseries-modules/aws//modules/subnet_set"
for_each = toset(distinct([for _, v in var.subnets : v.set]))
name = each.key
cidrs = { for k, v in var.subnets : k => v if v.set == each.key }
vpc_id = module.vmseries-vpc.vpc.id
global_tags = {
ManagedBy = "Terraform"
Application = "Advanced Demo"
Component = "New"
}
}
variable "public_security_group_id" {
default = "sg-0fe28f198c2cb4ee5"
}
variable "public_subnet_az_a" {
default = "subnet-077f8eaf3015a3eb1"
}
variable "public_subnet_az_b" {
default = "subnet-064297c82d311f44e"
}
module "vmseries1" {
source = "PaloAltoNetworks/vmseries-modules/aws//modules/vmseries"
name = "example-vmseries"
ssh_key_name = "terraform-demo"
bootstrap_options = "type=dhcp-client;hostname=vms01"
interfaces = {
mgmt = {
device_index = 0
security_groups = [module.vmseries-vpc.security_group_ids["vmseries_mgmt"]]
source_dest_check = true
subnet_id = module.subnet_sets["mgmt"].subnets["us-east-1a"].id
create_public_ip = true
}
public = {
device_index = 1
security_groups = [var.public_security_group_id]
source_dest_check = false
subnet_id = var.public_subnet_az_a
create_public_ip = true
}
private = {
device_index = 2
security_groups = [module.vmseries-vpc.security_group_ids["vmseries_private"]]
source_dest_check = false
subnet_id = module.subnet_sets["private"].subnets["us-east-1a"].id
create_public_ip = false
}
}
tags = {
ManagedBy = "Terraform"
Application = "Advanced Demo"
Component = "New"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment