0
votes

The for_each line is where I get the error "Expected the start of an expression, but found an invalid expression token." I want to create that action based on a boolean variable. I already created a dynamic stage which works fine, but this dynamic action doesn't work.

How can I dynamically create this action?

resource "aws_codepipeline" "codepipeline" {

  stage {

  name = "Build"

  dynamic "action" {
  for_each = local.DoGovCloud ? [<<EOT
      name = "BuildInGovcloud"
     ...
      }
      EOT
      ]: []
    }
}
1

1 Answers

0
votes
dynamic "action" {
  for_each = local.DoGovCloud ? ["DoGovCloud"]: []
  content {
    //... properties of the action
  }
}

Will make an action block with the arguments in the content block if the value of local.DoInGovCloud is true.