Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added variable to enable auto assigning public IPs to instances for public subnets #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ variable "sn_public_c_name" {
default = "Public C"
}

variable "auto_assign_public_ip" {
description = "Specify true to indicate that instances launched into the public subnets should be assigned a public IP address"
default = false
type = bool
}

// variable "sn_public_d_name" {
// description = "The name of the 4th Public Subnet which will be available in AZ-d."
// default = "Public d"
Expand Down
3 changes: 3 additions & 0 deletions vpc_subnets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ resource "aws_subnet" "sn_public_a" {
vpc_id = aws_vpc.main.id
cidr_block = (local.enable_dynamic_subnets == true ? var.public_subnets_a[count.index] : cidrsubnet(var.vpc_network, 3, 4))
availability_zone = local.az1
map_public_ip_on_launch = var.auto_assign_public_ip

tags = merge(
{
Expand All @@ -66,6 +67,7 @@ resource "aws_subnet" "sn_public_b" {
vpc_id = aws_vpc.main.id
cidr_block = (local.enable_dynamic_subnets == true ? var.public_subnets_b[count.index] : cidrsubnet(var.vpc_network, 3, 5))
availability_zone = local.az2
map_public_ip_on_launch = var.auto_assign_public_ip

tags = merge(
{
Expand All @@ -81,6 +83,7 @@ resource "aws_subnet" "sn_public_c" {
vpc_id = aws_vpc.main.id
cidr_block = (local.enable_dynamic_subnets == true ? var.public_subnets_c[count.index] : cidrsubnet(var.vpc_network, 3, 6))
availability_zone = local.az3
map_public_ip_on_launch = var.auto_assign_public_ip

tags = merge(
{
Expand Down