Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ locals {
subnet_name = var.subnet_name
subnet_cidr = var.subnet_cidr # create when cidr is given, otherwise select with name or skip
subnet_availability_zone = var.availability_zone # only used when creating
subnet_public_ip = var.subnet_public_ip # set this to true to enable public ip addressing on servers
skip_subnet = var.skip_subnet # if using the "specific" security group type you can skip subnet creation

security_group_name = var.security_group_name
Expand Down Expand Up @@ -43,6 +44,7 @@ module "subnet" {
vpc_id = module.vpc[0].id
owner = local.owner
availability_zone = local.subnet_availability_zone
public_ip = local.subnet_public_ip
}

module "security_group" {
Expand Down
10 changes: 6 additions & 4 deletions modules/subnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ locals {
vpc_id = var.vpc_id
owner = var.owner
availability_zone = var.availability_zone
public_ip = var.public_ip
}

data "aws_subnet" "selected" {
Expand All @@ -16,10 +17,11 @@ data "aws_subnet" "selected" {
}
}
resource "aws_subnet" "new" {
count = local.create
vpc_id = local.vpc_id
cidr_block = local.cidr
availability_zone = local.availability_zone
count = local.create
vpc_id = local.vpc_id
cidr_block = local.cidr
availability_zone = local.availability_zone
map_public_ip_on_launch = local.public_ip
tags = {
Name = local.name
Owner = local.owner
Expand Down
7 changes: 7 additions & 0 deletions modules/subnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ variable "availability_zone" {
EOT
default = ""
}
variable "public_ip" {
type = bool
description = <<-EOT
Set this to true to enable the subnet to have public IP addresses.
EOT
default = false
}
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ variable "subnet_cidr" {
EOT
default = ""
}
variable "subnet_public_ip" {
type = bool
description = <<-EOT
Set this to true to enable the subnet to have public IP addresses.
EOT
default = false
}
variable "availability_zone" {
type = string
description = <<-EOT
Expand Down