Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform Outputs - extract the value of output variables from the state file #418

Open
vincentclee opened this issue Feb 2, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@vincentclee
Copy link
Contributor

Is there a way to list outputs from the state file and use the values downstream?

Example

main.tf

...
output "instance_ips" {
  value = aws_instance.web.*.public_ip
}

output "lb_address" {
  value = aws_alb.web.public_dns
}

output "password" {
  sensitive = true
  value = var.secret_password
}

Jenkinsfile

Jenkinsfile.init(this)
def validate = new TerraformValidateStage()
def deployUat = new TerraformEnvironmentStage("uat")
validate.then(deployUat).build()

// proposed
def outputs = deployUat.getOutputs()
echo outputs
echo outputs["lb_address"]
$ terraform output
instance_ips = [
  "54.43.114.12",
  "52.122.13.4",
  "52.4.116.53"
]
lb_address = "my-app-alb-1657023003.us-east-1.elb.amazonaws.com"
password = <sensitive>

References

The terraform output command is used to extract the value of an output variable from the state file.

https://www.terraform.io/cli/commands/output

@kmanning kmanning added the enhancement New feature or request label Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants