In this step, you will first initialize your Terraform project and then run the terraform plan command to create an execution plan.
Before you can plan any changes, you must initialize the project. The terraform init command scans your configuration, downloads the required providers (in this case, for local_file), and sets up the backend.
In your terminal, first run terraform init:
terraform init
After initialization is successful, run terraform plan. This command is a crucial part of the Terraform workflow as it provides a "dry run" of the changes. It shows you what Terraform will do to your infrastructure without actually making any changes. This allows you to review and verify the intended actions before they are applied.
terraform plan
Terraform will read your configuration file and compare it to the current state of your infrastructure (which is currently empty). It will then display a plan of action. You should see output similar to the following, indicating that one resource is going to be created.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
## local_file.example will be created
+ resource "local_file" "example" {
+ content = "Hello, Terraform!"
+ content_base64sha256 = (known after apply)
+ content_base64sha512 = (known after apply)
+ content_md5 = (known after apply)
+ content_sha1 = (known after apply)
+ content_sha256 = (known after apply)
+ content_sha512 = (known after apply)
+ directory_permission = "0777"
+ file_permission = "0777"
+ filename = "./hello.txt"
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
The + symbol next to resource "local_file" "example" signifies that this resource will be created. The output details all the attributes that will be set on the new file.