Skip to content

Commit

Permalink
fix: 'failed: cannot use element function with an empty list' with si…
Browse files Browse the repository at this point in the history
…ngle_nat_gateway attribute (#62)
  • Loading branch information
h1manshu98 authored Nov 1, 2023
1 parent d1fe5e0 commit 1103c7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
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

0 comments on commit 1103c7a

Please sign in to comment.