Last active
March 19, 2022 17:20
-
-
Save w3bward/b7768578ea140382f8928e52fb847a6c to your computer and use it in GitHub Desktop.
The environment argument is a safer way to pass values to local-exec scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 1.1.6" | |
} | |
locals { | |
my_var = "12\" = 1'" | |
} | |
resource "null_resource" "good_example" { | |
triggers = { | |
my_var = local.my_var | |
always_run = "${timestamp()}" | |
} | |
provisioner "local-exec" { | |
interpreter = ["Powershell", "-Command"] | |
environment = { | |
MyVar = local.my_var | |
} | |
command = <<EOC | |
write-host "my_var value: $Env:MyVar" | |
EOC | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment