Skip to content

Commit

Permalink
Do not create "ipv6-private" aws_route when create_egress_only_intern…
Browse files Browse the repository at this point in the history
…et_gateway = false (#41)

"ipv6-private" aws_route resource is in creation even if there is no aws_egress_only_internet_gateway.

This causes these errors:

╷
│ Error: Invalid index
│
│   on ../../templates/telia-oss-vpc/main.tf line 168, in resource "aws_route" "ipv6-private":
│  168:   egress_only_gateway_id      = aws_egress_only_internet_gateway.outbound[0].id
│     ├────────────────
│     │ aws_egress_only_internet_gateway.outbound is empty tuple
│
│ The given key does not identify an element in this collection value: the collection has no elements.
╵
╷
│ Error: Invalid index
│
│   on ../../templates/telia-oss-vpc/main.tf line 168, in resource "aws_route" "ipv6-private":
│  168:   egress_only_gateway_id      = aws_egress_only_internet_gateway.outbound[0].id
│     ├────────────────
│     │ aws_egress_only_internet_gateway.outbound is empty tuple
│
│ The given key does not identify an element in this collection value: the collection has no elements.
╵
╷
│ Error: Invalid index
│
│   on ../../templates/telia-oss-vpc/main.tf line 168, in resource "aws_route" "ipv6-private":
│  168:   egress_only_gateway_id      = aws_egress_only_internet_gateway.outbound[0].id
│     ├────────────────
│     │ aws_egress_only_internet_gateway.outbound is empty tuple
│
│ The given key does not identify an element in this collection value: the collection has no elements.
  • Loading branch information
DaliborLis authored Mar 28, 2022
1 parent 792e4b2 commit 406fe0c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ resource "aws_route" "ipv6-private" {
aws_egress_only_internet_gateway.outbound,
aws_route_table.private,
]
count = length(var.private_subnet_cidrs) > 0 ? length(var.private_subnet_cidrs) : 0
count = length(var.private_subnet_cidrs) > 0 && local.egress_only_internet_gateway_count > 0 ? length(var.private_subnet_cidrs) : 0
route_table_id = aws_route_table.private[count.index].id
egress_only_gateway_id = aws_egress_only_internet_gateway.outbound[0].id
destination_ipv6_cidr_block = "::/0"
Expand Down

0 comments on commit 406fe0c

Please sign in to comment.