Difference between revisions of "Terraform output"
Jump to navigation
Jump to search
↑ https://www.terraform.io/docs/cli/commands/output.html
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{lowercase}} | + | {{lowercase}} <code>terraform output</code><ref>https://www.terraform.io/docs/cli/commands/output.html</ref> command is used to extract the value of an [[output variable]] from the [[state file]]. |
− | + | [[terraform]] output ([[terraform output --help|--help]]) | |
− | |||
− | |||
− | |||
− | |||
[[terraform output -json]] | [[terraform output -json]] | ||
+ | [[terraform output -raw]] | ||
+ | == Examples == | ||
terraform output | terraform output | ||
[[kubernetes_cluster_host]] = "35.225.206.41" | [[kubernetes_cluster_host]] = "35.225.206.41" | ||
Line 19: | Line 17: | ||
[[us-east-2]]% | [[us-east-2]]% | ||
− | [[terraform output -raw]] | + | [[terraform output -raw region]] |
[[us-east-1]]% | [[us-east-1]]% | ||
− | terraform output -raw | + | [[terraform output -raw cluster_name]] |
education-eks-Ry318DCv% | education-eks-Ry318DCv% | ||
Line 40: | Line 38: | ||
* <code>[[aws eks]] --region $([[terraform output]] -raw region) [[update-kubeconfig]] --name $(terraform output -raw cluster_name)</code> | * <code>[[aws eks]] --region $([[terraform output]] -raw region) [[update-kubeconfig]] --name $(terraform output -raw cluster_name)</code> | ||
− | |||
− | |||
== Related commands == | == Related commands == | ||
Line 52: | Line 48: | ||
== See also == | == See also == | ||
* {{terraform output}} | * {{terraform output}} | ||
− | * {{ | + | * {{tf state}} |
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 21:58, 11 February 2024
terraform output
[1] command is used to extract the value of an output variable from the state file.
terraform output (--help) terraform output -json terraform output -raw
Examples[edit]
terraform output kubernetes_cluster_host = "35.225.206.41" kubernetes_cluster_name = "cluster-name-gke" project_id = "your-project" region = "us-central1"
terraform output your_var
terraform output -raw region us-east-2%
terraform output -raw region us-east-1%
terraform output -raw cluster_name education-eks-Ry318DCv%
terraform output -raw region ╷ │ Warning: No outputs found │ │ The state file either has no outputs defined, or all the defined outputs are │ empty. Please define an output in your configuration with the `output` │ keyword and run `terraform refresh` for it to become available. If you are │ using interpolation, please verify the interpolated value is not empty. You │ can use the `terraform console` command to assist. ╵
aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)
Related commands[edit]
See also[edit]
terraform output [ -raw | -json | --help ]
terraform state [ list ]
Advertising: