Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 9851f27

Browse files
psibiketzacoatl
authored andcommitted
nat-gateways module: Avoid conversion to set to fix ordering issue
1 parent a7b028e commit 9851f27

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Modules
66

7+
* nat-gateways: Fix association issue caused between `nat_eip` and
8+
public subnets. This only affects resources using the `nat_eip` variable.
9+
710
### Examples
811

912
# v0.9.16

modules/nat-gateways/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ locals {
1515
# Number of new NATs to be created in case var.nat_eip is empty.
1616
total_new_nat = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? local.total_nat_count : 0) : 0
1717
# Gives the EIP ids. It would be either populated via data source or newly created (which is controlled by var.nat_eip).
18-
eip_ids = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? aws_eip.nat.*.id : values(data.aws_eip.nat)[*].id) : []
18+
eip_ids = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? aws_eip.nat.*.id : data.aws_eip.nat.*.id) : []
1919
}
2020

2121
# AWS Managed NAT Gateways
@@ -25,8 +25,8 @@ resource "aws_eip" "nat" {
2525
}
2626

2727
data "aws_eip" "nat" {
28-
for_each = length(var.nat_eip) != 0 ? toset(var.nat_eip) : toset([])
29-
public_ip = each.value
28+
count = length(var.nat_eip)
29+
public_ip = element(var.nat_eip, count.index)
3030
}
3131

3232
data "aws_subnet" "public" {

0 commit comments

Comments
 (0)