Skip to content

count logic does not work, bug or docs issue? #18015

Description

@flypenguin

Terraform Version

Terraform v0.11.7
+ provider.aws v1.17.0

Terraform Configuration Files

Attached as ZIP file. The relevant files are:

  • team-groups-policies.tf
  • helpers/group-role-with-policies/main.tf

The most relevant parts are:

# "main" tf file
module "team_ci_group" {
  source = "helpers/group-role-with-policies"

  create_group = 1
  team         = "team"
  name         = "ci"

  policies = [
    "arn:aws:iam::aws:policy/AWSBatchFullAccess",
    "${aws_iam_policy.gen_get_ecr_token.arn}",
  ]
}

... and ...

# module
resource "aws_iam_group" "group" {
  count = "${var.create_group}"
  name  = "${var.prefix}-${var.team}-${var.name}"
  path  = "/groups/${var.team}/"
}

resource "aws_iam_group_policy_attachment" "group_policy" {
  count = "${length(var.policies) * var.create_group }"

  group      = "${aws_iam_group.group.name}"
  policy_arn = "${element(var.policies, count.index)}"
}

Debug Output

In ZIP archive, a file called "TRACE"

Crash Output

No crash.

Expected Behavior

It should have created a group with two policy attachments.

Actual Behavior

Error message: * [...]: value of 'count' cannot be computed

Steps to Reproduce

  • Unzip
  • terraform init
  • terraform plan

Additional Context

N/A

References

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions