Skip to content

Commit d23bf4b

Browse files
bugfix: Restore wildcard splats
The version of terraform being used by the certification tests does not support the syntax the way it is currently on main. I need to modify it to use `.*.` syntax which works perfectly fine, but does trigger some tflint warnings which we now need to exclude.
1 parent 5bfa4c7 commit d23bf4b

7 files changed

Lines changed: 17 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
*.auto.tfvars.json

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ repos:
33
rev: v0.1.23
44
hooks:
55
- id: tflint
6+
args:
7+
- '--disable-rule=terraform_deprecated_index'
68
- id: terraform-validate
79
- id: terraform-fmt

customer-managed/aws/terraform/iam_redpanda_agent.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ data "aws_iam_policy_document" "redpanda_agent1" {
254254

255255
"arn:aws:ec2:*::image/*",
256256
],
257-
aws_subnet.private[*].arn)
257+
aws_subnet.private.*.arn)
258258
}
259259

260260
statement {

customer-managed/aws/terraform/iam_rpk_user.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ data "aws_iam_policy_document" "byovpc_rpk_user_1" {
9595
actions = [
9696
"ec2:DescribeSubnets",
9797
]
98-
resources = concat(tolist(aws_subnet.public[*].arn), tolist(aws_subnet.private[*].arn))
98+
resources = concat(tolist(aws_subnet.public.*.arn), tolist(aws_subnet.private.*.arn))
9999
}
100100

101101
statement {
@@ -330,7 +330,7 @@ data "aws_iam_policy_document" "byovpc_rpk_user_2" {
330330
actions = [
331331
"ec2:RunInstances",
332332
]
333-
resources = concat([aws_security_group.redpanda_agent.arn], tolist(aws_subnet.public[*].arn), tolist(aws_subnet.private[*].arn))
333+
resources = concat([aws_security_group.redpanda_agent.arn], tolist(aws_subnet.public.*.arn), tolist(aws_subnet.private.*.arn))
334334
}
335335

336336
statement {

customer-managed/aws/terraform/nat.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ resource "aws_internet_gateway" "redpanda" {
88

99
resource "aws_nat_gateway" "redpanda" {
1010
allocation_id = aws_eip.nat_gateway.id
11-
subnet_id = aws_subnet.public[*].id[0]
11+
subnet_id = aws_subnet.public[0].id
1212
depends_on = [
1313
aws_internet_gateway.redpanda,
1414
]
1515
}
1616

1717
resource "aws_route" "nat" {
1818
count = length(var.private_subnet_cidrs)
19-
route_table_id = aws_route_table.private[*].id[count.index]
19+
route_table_id = aws_route_table.private.*.id[count.index]
2020
destination_cidr_block = "0.0.0.0/0"
21-
nat_gateway_id = element(aws_nat_gateway.redpanda[*].id, count.index)
21+
nat_gateway_id = aws_nat_gateway.redpanda.id
2222
}
2323

2424
resource "aws_route" "public" {

customer-managed/aws/terraform/outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ output "vpc_arn" {
5151
}
5252

5353
output "public_subnet_ids" {
54-
value = jsonencode(aws_subnet.public[*].arn)
54+
value = jsonencode(aws_subnet.public.*.arn)
5555
description = "Public subnets IDs created"
5656
}
5757

5858
output "private_subnet_ids" {
59-
value = jsonencode(aws_subnet.private[*].arn)
59+
value = jsonencode(aws_subnet.private.*.arn)
6060
description = "Private subnet IDs created"
6161
}
6262

@@ -91,6 +91,6 @@ output "node_security_group_arn" {
9191
}
9292

9393
output "byovpc_rpk_user_policy_arns" {
94-
value = values(aws_iam_policy.byovpc_rpk_user)[*].arn
94+
value = jsonencode(values(aws_iam_policy.byovpc_rpk_user).*.arn)
9595
description = "ARNs of policies associated with the 'rpk user'. Can be used by Redpanda engineers to the assume the role and test provisioning with more limited access."
9696
}

customer-managed/aws/terraform/routing.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ resource "aws_main_route_table_association" "vpc-main-route-table" {
2121

2222
resource "aws_route_table_association" "public" {
2323
count = length(var.public_subnet_cidrs)
24-
subnet_id = aws_subnet.public[*].id[count.index]
24+
subnet_id = aws_subnet.public[count.index].id
2525
route_table_id = aws_route_table.main.id
2626
}
2727

2828
resource "aws_route_table_association" "private" {
2929
count = length(var.private_subnet_cidrs)
30-
subnet_id = aws_subnet.private[*].id[count.index]
31-
route_table_id = aws_route_table.private[*].id[count.index]
30+
subnet_id = aws_subnet.private[count.index].id
31+
route_table_id = aws_route_table.private[count.index].id
3232
}
3333

3434
# Routes S3 traffic to the local gateway endpoint
3535
resource "aws_vpc_endpoint_route_table_association" "private_s3" {
3636
count = length(var.private_subnet_cidrs)
3737
vpc_endpoint_id = aws_vpc_endpoint.s3.id
38-
route_table_id = aws_route_table.private[*].id[count.index]
38+
route_table_id = aws_route_table.private[count.index].id
3939
}
4040

4141
resource "aws_vpc_endpoint_route_table_association" "public_s3" {

0 commit comments

Comments
 (0)