terraform init → Initializes a Terraform project by downloading provider plugins and setting up the backend.
terraform validate → Checks the configuration for syntax errors.
terraform fmt → Formats the Terraform code according to best practices.
terraform plan → Creates an execution plan and shows what changes Terraform will apply without actually applying them.
terraform apply → Applies the changes to provision or modify infrastructure.
terraform destroy → Deletes all resources defined in the Terraform configuration.
terraform taint <resource> → Marks a resource for recreation in the next apply command
terraform import <resource> <ID> → Imports an existing resource into Terraform state.
*Storing Terraform State in an S3 Bucket with RDS Link*
Terraform state can be stored remotely in an AWS S3 bucket, ensuring better collaboration and security. Below is the configuration to store Terraform state in an S3 bucket while linking it with an RDS database.
To avoid conflicts when multiple users apply Terraform changes, enable state locking using DynamoDB
Key Benefits of Using S3 for Terraform State
✅ Remote Collaboration – Multiple team members can access the latest state.
✅ Versioning – Changes can be tracked over time with S3 versioning.
✅ Locking Mechanism – Prevents race conditions using DynamoDB locking.
✅ Security – Enables encryption and access control with IAM policies.
Comments
Post a Comment