Child resources as blocks and as different resources
- Added child resources as block and as different resources. Refer Here for the changeset which contains the above example
Files/Folders created during terraform apply or init
-
image
- .terraform folder consists of provider that got downloaded and going down the line modules will be downloaded here
-
.terraform.lock.hcl: This contains the info about provider downloaded with hashes of it
- terraform.tfstate: This is state file which contains info about state (what was created)
- terraform.tfstate.backup: This is state files backup which contains info about state (what was created) of last successful creation (n-1)
Terraform state
- Terraform state is like a record of what was created by terraform.
- This file by default will be created in the same folder where we execute terraform.
- This file should never be edited.
- Terraform looks into state for what was created
- Terraform applies the refresh operation to get the current state from the provider
- Then terraform finds the difference between desired state vs actual state. Difference will become plan
Case 1: Reapplying the terraform
- Refresh is applied and then terraform finds the desired state is already available and does nothing
Case 2: Resource is changed manually after creation by terraform
- Refresh is applied, changes will be found
- Plan will be created According to the provider, this might be update in place or replacement
Case 3: Resource is deleted manually after creation by terraform
- Refresh is applied, changes will be found
- Plan will be created to recreate
Case 4: state is deleted
- Terraform forgets about what it has done in the past and treats it as new resource creation.
Terraform state operations
- Showing state

-
list state
- Refer Here for sample used in class.
Optional type attributes
- Refer Here
- Refer Here for the example
