Difference between revisions of "Terraform plan"

From wikieduonline
Jump to navigation Jump to search
 
(72 intermediate revisions by 6 users not shown)
Line 1: Line 1:
* https://www.terraform.io/docs/cli/commands/plan.html
+
{{lowercase}}
 +
<code>[[terraform]] plan</code> ([https://www.terraform.io/docs/cli/commands/plan.html doc]) creates an [[execution plan]].
  
== Examples ==
+
{{terraform flow}}
  
=== aws_instance example ===
+
== Command examples ==
<pre>
+
* <code>[[terraform plan --help]]</code>
terraform plan
+
* <code>[[-no-color]]</code>
 +
* <code>terraform plan [[-out]]=tfplan.out</code>
 +
* <code>terraform plan [[-out]]=[[tfplan]]</code>
 +
* <code>[[terraform plan -lock=false]]</code>
 +
* <code>terraform plan [[-var-file]]="your_file.tfvars"</code>
 +
* <code>[[terraform]] plan -var=XXXX</code>
 +
* <code>terraform plan [[-replace]]=XXXX</code>
 +
* <code>[[terraform plan -target]]</code>
 +
* <code>[[terraform plan -refresh-only]]</code>
 +
* <code>[[terraform plan -parallelism]]</code>
 +
* <code>terraform plan | [[more -R]]</code>
  
Terraform used the selected providers to generate the following execution plan. Resource actions are
+
https://www.terraform.io/cli/commands/plan#planning-options
indicated with the following symbols:
+
-refresh=false
  + create
+
-replace=ADDRESS
 +
[[terraform plan -target]]=ADDRESS
  
Terraform will perform the following actions:
 
  
  # aws_instance.example will be created
+
tf plan 2>&1
  + resource "aws_instance" "example" {
 
      + ami                                  = "ami-08d70e59c07c61a3a"
 
      + arn                                  = (known after apply)
 
      + associate_public_ip_address          = (known after apply)
 
      + availability_zone                    = (known after apply)
 
      + cpu_core_count                      = (known after apply)
 
      + cpu_threads_per_core                = (known after apply)
 
      + disable_api_termination              = (known after apply)
 
      + ebs_optimized                        = (known after apply)
 
      + get_password_data                    = false
 
      + host_id                              = (known after apply)
 
      + id                                  = (known after apply)
 
      + instance_initiated_shutdown_behavior = (known after apply)
 
      + instance_state                      = (known after apply)
 
      + instance_type                        = "t2.micro"
 
      + ipv6_address_count                  = (known after apply)
 
      + ipv6_addresses                      = (known after apply)
 
      + key_name                            = (known after apply)
 
      + monitoring                          = (known after apply)
 
      + outpost_arn                          = (known after apply)
 
      + password_data                        = (known after apply)
 
      + placement_group                      = (known after apply)
 
      + primary_network_interface_id        = (known after apply)
 
      + private_dns                          = (known after apply)
 
      + private_ip                          = (known after apply)
 
      + public_dns                          = (known after apply)
 
      + public_ip                            = (known after apply)
 
      + secondary_private_ips                = (known after apply)
 
      + security_groups                      = (known after apply)
 
      + source_dest_check                    = true
 
      + subnet_id                            = (known after apply)
 
      + tags                                = {
 
          + "Name" = "ExampleAppServerInstance"
 
        }
 
      + tags_all                            = {
 
          + "Name" = "ExampleAppServerInstance"
 
        }
 
      + tenancy                              = (known after apply)
 
      + user_data                            = (known after apply)
 
      + user_data_base64                    = (known after apply)
 
      + vpc_security_group_ids              = (known after apply)
 
  
      + capacity_reservation_specification {
+
== Execution examples ==
          + capacity_reservation_preference = (known after apply)
+
* [[Examples: terraform plan]]
 +
* [[Terraform plan execution with errors]]
  
          + capacity_reservation_target {
+
== Errors ==
              + capacity_reservation_id = (known after apply)
+
* <code>[[Error: Reference to undeclared input variable]]</code>
            }
 
        }
 
  
      + ebs_block_device {
 
          + delete_on_termination = (known after apply)
 
          + device_name          = (known after apply)
 
          + encrypted            = (known after apply)
 
          + iops                  = (known after apply)
 
          + kms_key_id            = (known after apply)
 
          + snapshot_id          = (known after apply)
 
          + tags                  = (known after apply)
 
          + throughput            = (known after apply)
 
          + volume_id            = (known after apply)
 
          + volume_size          = (known after apply)
 
          + volume_type          = (known after apply)
 
        }
 
  
      + enclave_options {
+
  2024-07-03T13:44:35.311Z [WARN]  Provider "[[registry.terraform.io]]/datadog/datadog" produced an invalid plan for datadog_user.yourusers["yourusername"], but we are tolerating it because it is using the [[legacy plugin SDK]].
          + enabled = (known after apply)
+
    The following problems may be the cause of any confusing errors from downstream operations:
        }
+
      - .send_user_invitation: planned value cty.True for a non-computed ...
 
 
      + ephemeral_block_device {
 
          + device_name = (known after apply)
 
          + no_device    = (known after apply)
 
          + virtual_name = (known after apply)
 
        }
 
 
 
      + metadata_options {
 
          + http_endpoint              = (known after apply)
 
          + http_put_response_hop_limit = (known after apply)
 
          + http_tokens                = (known after apply)
 
        }
 
 
 
      + network_interface {
 
          + delete_on_termination = (known after apply)
 
          + device_index          = (known after apply)
 
          + network_interface_id  = (known after apply)
 
        }
 
 
 
      + root_block_device {
 
          + delete_on_termination = (known after apply)
 
          + device_name          = (known after apply)
 
          + encrypted            = (known after apply)
 
          + iops                  = (known after apply)
 
          + kms_key_id            = (known after apply)
 
          + tags                  = (known after apply)
 
          + throughput            = (known after apply)
 
          + volume_id            = (known after apply)
 
          + volume_size          = (known after apply)
 
          + volume_type          = (known after apply)
 
        }
 
    }
 
 
 
Plan: 1 to add, 0 to change, 0 to destroy.
 
 
 
─────────────────────────────────────────────────────────────────────────────────────────────────────────
 
 
 
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly
 
these actions if you run "terraform apply" now.
 
</pre>
 
 
 
=== No changes. Infrastructure is up-to-date ===
 
terraform plan
 
Refreshing Terraform state in-memory prior to plan...
 
The refreshed state will be used to calculate this plan, but will not be
 
persisted to local or remote state storage.
 
------------------------------------------------------------------------
 
No changes. Infrastructure is up-to-date.
 
 
This means that Terraform did not detect any differences between your
 
configuration and real physical resources that exist. As a result, no
 
actions need to be performed.
 
 
 
=== Error: undeclared resource ===
 
  terraform plan
 
 
│ Error: Reference to undeclared resource
 
 
│  on main.tf line 9, in resource "aws_instance" "example":
 
│    9:  [[ami]]               = data.aws_ami.windows.id
 
 
│ A data resource "aws_ami" "windows" has not been declared in the root module.
 
 
 
 
=== No configuration files ===
 
terraform plan
 
 
Error: No configuration files
 
 
Plan requires configuration to be present. Planning without a configuration
 
would mark everything for destruction, which is normally not what is desired.
 
If you would like to destroy everything, run plan with the -destroy option.
 
Otherwise, create a Terraform configuration file (.tf file) and try again.
 
  
 
== Related terms ==
 
== Related terms ==
* [[Terraform: Hello_world.tf]]
+
* [[Terraform examples]]: [[Terraform: Hello_world.tf]]
 
* [[GitLab]] Preview of summary of <code>terraform plan</code> in [[Merge Requests]] https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-released/#review-summary-of-terraform-plan-in-merge-requests
 
* [[GitLab]] Preview of summary of <code>terraform plan</code> in [[Merge Requests]] https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-released/#review-summary-of-terraform-plan-in-merge-requests
* <code>[[terraform validate]]</code>
+
* <code>[[terraform validate]], [[terraform apply]], [[terraform show]]</code>
 +
* <code>[[aws cloudformation list-change-sets]]</code>
 +
* <code>[[aws cloudformation describe-change-set]]</code>
 +
* <code>[[terragrunt plan]]</code>
 +
* <code>[[terraform debug]]</code>
 +
* <code>[[export TF_LOG=DEBUG]]</code>
 +
* [[ReferenceTransformer]]
 +
* <code>[[Plan: 0 to add, 0 to change, 0 to destroy.]]</code>
 +
* <code>[[terraform test]]</code>
  
 
== See also ==
 
== See also ==
* {{terraform cmd}}
+
* {{terraform plan}}
* {{terraform}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 13:56, 3 July 2024

terraform plan (doc) creates an execution plan.

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

Command examples[edit]

https://www.terraform.io/cli/commands/plan#planning-options

-refresh=false
-replace=ADDRESS
terraform plan -target=ADDRESS


tf plan 2>&1

Execution examples[edit]

Errors[edit]


2024-07-03T13:44:35.311Z [WARN]  Provider "registry.terraform.io/datadog/datadog" produced an invalid plan for datadog_user.yourusers["yourusername"], but we are tolerating it because it is using the legacy plugin SDK.
   The following problems may be the cause of any confusing errors from downstream operations:
     - .send_user_invitation: planned value cty.True for a non-computed ...

Related terms[edit]

See also[edit]

Advertising: