๐ถ Task 1: Find the purpose of basic Terraform commands which you'll use often
Terraform is a popular Infrastructure as Code (IaC) tool used to provision and manage infrastructure resources. There are several basic Terraform commands that you'll use frequently when working with Terraform to manage your infrastructure. Here are the purposes of these commonly used Terraform commands:
terraform init:
Purpose: Initializes a new or existing Terraform working directory.
Usage: Run this command in your Terraform project directory to download the necessary provider plugins and modules.
terraform plan:
Purpose: Generates an execution plan that shows what actions Terraform will take to achieve the desired infrastructure state defined in your configuration files.
Usage: Use this command to review and validate the changes that Terraform will make before actually applying them.
terraform apply:
Purpose: Applies the changes defined in your Terraform configuration to create, update, or delete resources to match the desired state.
Usage: Run this command to execute the changes after you've reviewed the plan and are ready to make modifications to your infrastructure.
terraform destroy:
Purpose: Destroys all resources created by Terraform for a specific configuration, effectively cleaning up your infrastructure.
Usage: Use this command when you want to tear down resources that are no longer needed.
terraform show:
Purpose: Displays the current state or saved execution plan in a human-readable format.
Usage: Useful for reviewing the current state of resources, especially when you need to check the status of your infrastructure.
terraform state:
Purpose: Provides subcommands to inspect and modify the Terraform state file, which contains information about the current state of resources.
Usage: You can use this to import existing resources into Terraform or to manage state.
terraform refresh:
Purpose: Updates the Terraform state file to reflect the real-world state of the infrastructure by querying the provider APIs.
Usage: Useful when you want to refresh the state file without making any changes.
terraform output:
Purpose: Displays the values of output variables defined in your Terraform configuration.
Usage: Helps you retrieve information about your infrastructure that is exposed as outputs.
terraform import:
Purpose: Imports existing infrastructure resources into your Terraform state, allowing you to manage them using Terraform.
Usage: When you have pre-existing resources that you want to manage with Terraform, this command is used to import them.
terraform workspace:
Purpose: Manages multiple workspaces, which are isolated environments for your Terraform configurations.
Usage: Useful when you need to work with different configurations or environments (e.g., development, staging, production) within the same project.
These are some of the fundamental Terraform commands that you'll frequently use to create, modify, and manage your infrastructure as code. Terraform offers a wide range of additional commands and options for more advanced use cases and troubleshooting.
Happy Learning :)
If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! ๐ #devops #90daysofdevop #AWS