Difference between revisions of "Terraform show"

From wikieduonline
Jump to navigation Jump to search
 
(83 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{lowercase}}
 +
<code>terraform show</code> command provides human-readable output from a [[Terraform state files|state]] or [[plan file]].
 
* https://www.terraform.io/docs/cli/commands/show.html
 
* https://www.terraform.io/docs/cli/commands/show.html
  
  [[terraform show --help]]
+
* <code>[[terraform show]]</code>
 +
* <code>[[terraform show -no-color]]</code>
 +
* <code>[[terraform show -json]]</code>
 +
* <code>[[terraform show --help]]</code>
 +
 
 +
  {{terraform flow}}
 +
 
 +
== Examples ==
 +
* <code>[[terraform show (output example)]]</code> (output example)
 +
* <code>terraform show | egrep -w "^[[resource]] |^[[data]] " | grep -v "#"</code>
 +
* <code>[[terraform show (grep resource) | terraform show | grep -w resource]]</code>
 +
* <code>[[terraform]] show | grep #</code>
 +
* <code>terraform show | grep -w data | grep -v "#"</code>
 +
* <code>terraform show | egrep -w "instance_state|public_ip"</code>
 +
* <code>terraform show | grep -w [[public_ip]]</code>
 +
* <code>terraform show | grep -w [[Name]]</code>
 +
* <code>terraform show | grep [[instance_type]]</code>
 +
* <code>terraform show | grep [[instance_state]]</code>
 +
* [[terraform]] show | grep -w [[endpoint]]
 +
* [[Terraform show output example aws_instance]]
 +
 
 +
[[aws_db_instance|RDS]]
 +
terraform show | grep [[.rds.amazonaws.com]]
 +
terraform show | grep -w [[endpoint]]
  
 
  terraform show
 
  terraform show
  No state.
+
  [[No state]].
  
== Output Example ==
 
<pre>
 
 
  terraform show
 
  terraform show
# aws_instance.app_server:
+
(no output)
resource "aws_instance" "app_server" {
 
    ami                                  = "ami-830c94e3"
 
    arn                                  = "arn:aws:ec2:us-west-2:672850566589:instance/i-0598bc37b772faaa3"
 
    associate_public_ip_address          = true
 
    availability_zone                    = "us-west-2a"
 
    cpu_core_count                      = 1
 
    cpu_threads_per_core                = 1
 
    disable_api_termination              = false
 
    ebs_optimized                        = false
 
    get_password_data                    = false
 
    hibernation                          = false
 
    id                                  = "i-0598bc37b772faaa3"
 
    instance_initiated_shutdown_behavior = "stop"
 
    instance_state                      = "running"
 
    instance_type                        = "t2.micro"
 
    ipv6_address_count                  = 0
 
    ipv6_addresses                      = []
 
    monitoring                          = false
 
    primary_network_interface_id        = "eni-0cf3cce58b77056bb"
 
    private_dns                          = "ip-172-31-24-141.us-west-2.compute.internal"
 
    private_ip                          = "172.31.24.141"
 
    public_dns                          = "ec2-54-202-75-92.us-west-2.compute.amazonaws.com"
 
    public_ip                            = "54.202.75.92"
 
    secondary_private_ips                = []
 
    security_groups                      = [
 
        "default",
 
    ]
 
    source_dest_check                    = true
 
    subnet_id                            = "subnet-6551cf1d"
 
    tags                                = {
 
        "Name" = "ExampleAppServerInstance"
 
    }
 
    tags_all                            = {
 
        "Name" = "ExampleAppServerInstance"
 
    }
 
    tenancy                              = "default"
 
    vpc_security_group_ids              = [
 
        "sg-a95bbfa2",
 
    ]
 
  
    capacity_reservation_specification {
+
[[terragrunt show]]
        capacity_reservation_preference = "open"
 
    }
 
  
    credit_specification {
+
== Examples with errors ==
        cpu_credits = "standard"
+
terraform show
    }
+
 +
│ [[Error: Module not installed]]
 +
 +
│  on /path_to_file/main.tf line 3:
 +
│    3: module "[[compute]]" {
 +
 +
│ This module is not yet installed. Run "[[terraform init]]" to install all modules required by this configuration.
 +
  
    enclave_options {
+
│ [[Error: Backend initialization required, please run "terraform init"]]
        enabled = false
 
    }
 
  
    metadata_options {
 
        http_endpoint              = "enabled"
 
        http_put_response_hop_limit = 1
 
        http_tokens                = "optional"
 
    }
 
  
    root_block_device {
+
[[Error: failed to read the give file as a state or plan file]]
        delete_on_termination = true
 
        device_name          = "/dev/sda1"
 
        encrypted            = false
 
        iops                  = 0
 
        tags                  = {}
 
        throughput            = 0
 
        volume_id            = "vol-0c66c62a8d104731f"
 
        volume_size          = 8
 
        volume_type          = "standard"
 
    }
 
}
 
</pre>
 
  
 +
 +
[[Error: Invalid or missing required argument]]
 +
 +
 +
* <code>[[terraform show my_wrong_name]]</code>
  
 
== Changelog ==
 
== Changelog ==
* terraform show: The [[JSON]] plan output now indicates which state values are sensitive. (#28889)
+
* <code>terraform show</code>: the [[JSON]] plan output now indicates which state values are sensitive. (#28889)
  
 
== Related terms ==
 
== Related terms ==
 
* <code>[[terraform state list]]</code>
 
* <code>[[terraform state list]]</code>
* <code>[[terraform state show aws_instance.MYexample</code>
+
* <code>[[terraform state pull]]</code>
 +
* <code>[[terraform state show]]</code>
 +
* <code>[[terraform state show aws_instance.MYexample]]</code>
 +
* <code>[[terraform apply -replace]]</code>
 +
 
 +
* <code>[[terraform destroy]]</code>
 +
* <code>[[terraform output]]</code>
 +
* <code>[[terraform plan -refresh-only]]</code>
 +
* <code>[[terragrunt show]]</code>
 +
* [[terraform workspace show]]
 +
* [[helm show all]]
 +
 
 +
== Errors ==
 +
* <code>[[Error: Module not installed]]</code>
 +
* [[Error: Failed to read the given file as a state or plan file]]
  
 
== See also ==
 
== See also ==
* {{terraform cmd}}
+
* {{terraform show}}
* {{terraform}}
+
* {{terraform state}}
 
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 09:20, 23 July 2024

terraform show command provides human-readable output from a state or plan file.

 terraform init -> terraform plan ->  terraform apply -> terraform show

Examples[edit]

RDS

terraform show | grep .rds.amazonaws.com
terraform show | grep -w endpoint
terraform show
No state.
terraform show
(no output)
terragrunt show

Examples with errors[edit]

terraform show
╷
│ Error: Module not installed
│
│   on /path_to_file/main.tf line 3:
│    3: module "compute" {
│
│ This module is not yet installed. Run "terraform init" to install all modules required by this configuration.
╵
Error: Backend initialization required, please run "terraform init"


Error: failed to read the give file as a state or plan file


Error: Invalid or missing required argument


Changelog[edit]

  • terraform show: the JSON plan output now indicates which state values are sensitive. (#28889)

Related terms[edit]

Errors[edit]

See also[edit]

Advertising: