Created
June 20, 2022 18:22
-
-
Save bencord0/8ff7e9b3e4a1bcb01b17ad4c0dd55cb2 to your computer and use it in GitHub Desktop.
Extracting secret environment variables from Terraform Cloud
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 { | |
backend "remote" { | |
hostname = "app.terraform.io" | |
organization = "secret-org" | |
workspaces { | |
name = "secret-workspace" | |
} | |
} | |
required_providers { | |
external = { | |
source = "hashicorp/external" | |
version = "2.2.2" | |
} | |
} | |
} | |
provider "external" {} |
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
#!/bin/bash | |
echo "{\"value\":\"$MY_SECRET_VARIABLE\"}" |
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
data "external" "secret" { | |
program = ["${path.module}/secret.sh"] | |
} | |
output "secret" { | |
value = data.external.secret.result.value | |
} |
Author
bencord0
commented
Jun 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment