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

Fix: single_nat_gateway with enable=false attribute #62

Merged
merged 1 commit into from
Nov 1, 2023
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
26 changes: 17 additions & 9 deletions _example/complete/example.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
provider "aws" {
region = "eu-west-1"
region = local.region
}

locals {
name = "app"
environment = "test"
region = "eu-west-1"
}

##-----------------------------------------------------------------------------
## Vpc Module call.
##-----------------------------------------------------------------------------
module "vpc" {
source = "clouddrove/vpc/aws"
version = "2.0.0"
name = local.name
environment = local.environment
source = "clouddrove/vpc/aws"
version = "2.0.0"

enable = true
name = local.name
environment = local.environment

cidr_block = "10.0.0.0/16"
enable_flow_log = true # Flow logs will be stored in cloudwatch log group. Variables passed in default.
create_flow_log_cloudwatch_iam_role = true
Expand All @@ -31,11 +35,15 @@ module "vpc" {
#tfsec:ignore:aws-ec2-no-excessive-port-access
#tfsec:ignore:aws-ec2-no-public-ingress-acl
module "subnets" {
source = "./../../"
name = local.name
environment = local.environment
source = "./../../"

enable = true
name = local.name
environment = local.environment

nat_gateway_enabled = true
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
single_nat_gateway = true
availability_zones = ["${local.region}a", "${local.region}b", "${local.region}c"]
vpc_id = module.vpc.vpc_id
type = "public-private"
igw_id = module.vpc.igw_id
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
locals {
public_count = var.enable == true && (var.type == "public" || var.type == "public-private") ? length(var.availability_zones) : 0
private_count = var.enable == true && (var.type == "private" || var.type == "public-private") ? length(var.availability_zones) : 0
nat_gateway_count = var.single_nat_gateway ? 1 : (var.enable == true && (var.type == "private" || var.type == "public-private") && var.nat_gateway_enabled == true ? length(var.availability_zones) : 0)
nat_gateway_count = var.enable == true && var.single_nat_gateway ? 1 : (var.enable == true && (var.type == "private" || var.type == "public-private") && var.nat_gateway_enabled == true ? length(var.availability_zones) : 0)
}
##-----------------------------------------------------------------------------
## Labels module called that will be used for naming and tags.
Expand Down