scottwinkler / terraform-provider-shell

Terraform provider for executing shell commands and saving output to state file
Mozilla Public License 2.0
279 stars 60 forks source link

Support list/map type for environment argument #110

Open dung-leviethoang-mox opened 2 years ago

dung-leviethoang-mox commented 2 years ago

There is a case we need a list of value as environment variable and pass in the script to do the loop. It would be great if the environment argument support more than just string.

For example

data "shell_script" "example" {
  lifecycle_commands {
    read = <<-EOF
          bash main.sh
        EOF
  }

  environment = {
    TF_SUPPORTED_VERSION = ["1.0", "1.1", "1.2"]
  }

  working_directory = "./sources"
}
pauldraper commented 1 year ago

Environments variables are strings.

stevehipwell commented 8 months ago

It's relatively straightforward to do this currently. I either use jsonencode(local.list) if the value is complex or want to process it with jq or for a simple structure like a list of strings I use join(" ", local.list).