Skip to content

Instantly share code, notes, and snippets.

@bencord0
Created June 20, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bencord0/8ff7e9b3e4a1bcb01b17ad4c0dd55cb2 to your computer and use it in GitHub Desktop.
Save bencord0/8ff7e9b3e4a1bcb01b17ad4c0dd55cb2 to your computer and use it in GitHub Desktop.
Extracting secret environment variables from Terraform Cloud
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" {}
#!/bin/bash
echo "{\"value\":\"$MY_SECRET_VARIABLE\"}"
data "external" "secret" {
program = ["${path.module}/secret.sh"]
}
output "secret" {
value = data.external.secret.result.value
}
@bencord0
Copy link
Author

Changes to Outputs:
  + secret = {
      + id          = "-"
      + program     = [
          + "./secret.sh",
        ]
      + query       = null
      + result      = {
          + "value" = "hunter3"
        }
      + working_dir = null
    }

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