Skip to content
Open
6 changes: 3 additions & 3 deletions modules/webhook/webhook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ locals {
}

resource "aws_ssm_parameter" "runner_matcher_config" {
for_each = { for idx, val in local.matcher_chunks : idx => val }
count = length(local.matcher_chunks)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This count still results in my case in the following error with a large configuration:

Plan: 118 to add, 7 to change, 0 to destroy.
╷
│ Error: Invalid count argument
│
│   on ../../modules/webhook/webhook.tf line 27, in resource "aws_ssm_parameter" "runner_matcher_config":
│   27:   count = length(local.matcher_chunks)
│
│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around
│ this, use the -target argument to first apply only the resources that the count depends on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edersonbrilhante just tested with the example multi-runner in the repo. With about 4 extra config files with quite some labels. But ending up with the error above.


name = "${var.ssm_paths.root}/${var.ssm_paths.webhook}/runner-matcher-config${length(local.matcher_chunks) > 1 ? "-${each.key}" : ""}"
name = "${var.ssm_paths.root}/${var.ssm_paths.webhook}/runner-matcher-config${length(local.matcher_chunks) > 1 ? "-${count.index}" : ""}"
type = "String"
value = each.value
value = local.matcher_chunks[count.index]
tier = var.matcher_config_parameter_store_tier
}

Expand Down