add output, deployment and clean up content (#6115)

* add output, deployment and clean up content

* Update src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md

add period

* Apply suggestions from code review

Committed suggested changes.

Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>

---------

Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>
pull/6117/head
dsh 5 months ago committed by GitHub
parent 830aae4d9c
commit d1a698447d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      src/data/roadmaps/terraform/content/clean-up@inbTto9Qukdj6egRJ0Zh9.md
  2. 10
      src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md
  3. 13
      src/data/roadmaps/terraform/content/format--validate@Xes24SqkwSaO844kLbClj.md
  4. 19
      src/data/roadmaps/terraform/content/output-syntax@31fa8kBzCEn-uCrTSoPM4.md
  5. 18
      src/data/roadmaps/terraform/content/sensitive-outputs@8giL6H5944M2L0rwxjPso.md
  6. 8
      src/data/roadmaps/terraform/content/terraform-apply@LDpj-LY_SOXzno04D-Y25.md
  7. 8
      src/data/roadmaps/terraform/content/terraform-destroy@LPI13FILvkD55hWcWbPrV.md
  8. 8
      src/data/roadmaps/terraform/content/terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md
  9. 8
      src/data/roadmaps/terraform/content/terraform-plan@LDxAXmTKyvogvgUpvN5pT.md
  10. 10
      src/data/roadmaps/terraform/content/tflint@YftsQYpcqJqBKPjy5tWOq.md

@ -1 +1,7 @@
# Clean Up
Cleaning up after using Terraform involves removing the infrastructure resources created and managing the associated state. The primary command for this is `terraform destroy`, which deletes all resources managed by the current Terraform configuration. It shows a destruction plan and requires confirmation before proceeding. After destruction, you should remove or archive the state files if they're no longer needed. For partial cleanup, you can remove specific resources from the state using `terraform state rm` and then run `terraform apply` to delete them. It's crucial to ensure all resources are properly removed to avoid unnecessary costs and security risks. Always review the destruction plan carefully, especially in shared or production environments, to prevent accidental deletion of critical resources.
Learn more from the following resources:
- [@article@How to Destroy Terraform Resources](https://spacelift.io/blog/how-to-destroy-terraform-resources)

@ -1 +1,11 @@
# Deployment
Deploying Terraform-defined infrastructure involves several key steps:
- Initialize the working directory with `terraform init`
- Review changes with `terraform plan`
- Apply the configuration using `terraform apply`.
You can learn more from the following resources:
- [@article@The Core Terraform Workflow](https://developer.hashicorp.com/terraform/intro/core-workflow)

@ -1 +1,14 @@
# Format & Validate
Terraform `format` and `validate` are two essential commands for maintaining clean and correct Terraform configurations:
- `terraform fmt` automatically formats Terraform configuration files to a consistent style. It adjusts indentation, aligns arguments, and sorts blocks and arguments. This command helps maintain code readability and consistency across team projects.
- `terraform validate` checks the syntax and internal consistency of Terraform configurations. It verifies that the configuration is syntactically valid, references are correct, and attribute names and types are appropriate. This command catches errors early in the development process, before attempting to apply changes to infrastructure.
You can learn more about these using the following resources
- [@article@Validate, format, lint, secure, and test Terraform IaC](https://tech.aabouzaid.com/2020/04/validate-format-lint-and-test-terraform-iac-ci.html)
- [@official@Terraform Validate - Documentation](https://developer.hashicorp.com/terraform/cli/commands/validate)
- [@official@Terraform Format - Documentation](https://developer.hashicorp.com/terraform/cli/commands/fmt)
- [@article@Terraform Validate Command – Validate Configuration Locally](https://spacelift.io/blog/terraform-validate)

@ -1 +1,20 @@
# Output Syntax
Terraform output syntax is used to define values that should be made accessible after applying a Terraform configuration. The basic syntax is:
```hcl
output "name" {
value = expression
description = "Optional description"
sensitive = bool
}
```
`name` is a unique identifier for the output. `value` is the expression whose result will be output. `description` is optional and provides context. `sensitive` is a boolean flag to mark sensitive data.
Learn more from the following resources:
- [@course@Hashicorp Output Tutorial](https://developer.hashicorp.com/terraform/tutorials/configuration-language/outputs)
- [@official@Declaring an output value](https://developer.hashicorp.com/terraform/language/values/outputs#declaring-an-output-value)
- [@article@Terraform Output Values : Complete Guide & Examples](https://spacelift.io/blog/terraform-output)
- [@article@Terraform: Output a field from a module](https://stackoverflow.com/questions/47034515/terraform-output-a-field-from-a-module)

@ -1 +1,19 @@
# Sensitive Outputs
Terraform sensitive outputs are a feature used to protect sensitive information in Terraform configurations. When an output is marked as sensitive, Terraform obscures its value in the console output and state files, displaying it as "<sensitive>" instead of the actual value. This is crucial for protecting sensitive data like passwords or API keys.
To mark an output as sensitive, use the sensitive argument in the output block:
```hcl
output "database_password" {
value = aws_db_instance.example.password
sensitive = true
}
```
Sensitive outputs are still accessible programmatically, but their values are hidden in logs and the console to prevent accidental exposure. This feature helps maintain security when sharing Terraform configurations or outputs with team members or in CI/CD pipelines.
Learn more from the following resources:
- [@article@How to output sensitive data in Terraform](https://support.hashicorp.com/hc/en-us/articles/5175257151891-How-to-output-sensitive-data-with-Terraform)
- [@official@Surpressing values in CLI output](https://developer.hashicorp.com/terraform/language/values/outputs#sensitive-suppressing-values-in-cli-output)

@ -1 +1,9 @@
# terraform apply
`terraform apply` is the command used to implement the changes defined in your Terraform configuration files. It creates, updates, or deletes the specified infrastructure resources to match the desired state. Before making changes, it shows a plan similar to terraform plan and prompts for confirmation, unless the -auto-approve flag is used. Apply updates the state file to reflect the current infrastructure state, enabling Terraform to track and manage resources over time. It handles dependencies between resources, creating them in the correct order.
Learn more from the following resoureces:
- [@official@Terraform Apply Documentation](https://developer.hashicorp.com/terraform/cli/commands/plan)
- [@course@Apply Terraform configuration](https://developer.hashicorp.com/terraform/tutorials/cli/apply)
- [@article@Terraform Apply Command: Options, Examples and Best Practices](https://www.env0.com/blog/terraform-apply-guide-command-options-and-examples)

@ -1 +1,9 @@
# terraform destroy
terraform destroy is a command used to remove all resources managed by a Terraform configuration. It creates a plan to delete all resources and prompts for confirmation before execution. This command is useful for cleaning up temporary environments or decommissioning entire infrastructures. It removes resources in the reverse order of their dependencies to ensure proper teardown. While powerful, terraform destroy should be used cautiously, especially in shared or production environments, as it can lead to data loss if not carefully managed. It's often used in conjunction with terraform state commands for more granular control over resource removal. After destruction, Terraform updates the state file to reflect the changes, but it's important to manage or remove this file if the project is being completely decommissioned.
Learn more from the following resources:
- [@official@Terraform Destroy Documentation](https://developer.hashicorp.com/terraform/cli/commands/destroy)
- [@article@How to destroy Terraform resources](https://spacelift.io/blog/how-to-destroy-terraform-resources)
- [@course@Destroy infrastructure](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-destroy)

@ -1 +1,9 @@
# terraform fmt
terraform fmt is a command in Terraform that automatically formats configuration files to a consistent style. It adjusts indentation, aligns arguments, and sorts blocks and arguments alphabetically. The command rewrites Terraform configuration files (.tf and .tfvars) in the current directory and its subdirectories. It's used to maintain a consistent coding style across projects and teams, improving readability and reducing merge conflicts. The command can be run with options like -recursive to format files in subdirectories, -diff to show the differences, or -check to validate formatting without making changes. Regularly using terraform fmt is considered a best practice in Terraform development workflows.
Learn more from the following resources:
- [@official@Terraform fmt Documentation](https://developer.hashicorp.com/terraform/cli/commands/fmt)
- [@article@Using Terraform fmt Command to Format Your Terraform Code](https://spacelift.io/blog/terraform-fmt)
- [@video@How to auto-format Terraform code](https://www.youtube.com/watch?v=kZX3KLOZvhY)

@ -1 +1,9 @@
# terraform plan
`terraform plan` is a command that creates an execution plan, showing what changes Terraform will make to your infrastructure. It compares the current state with the desired state defined in configuration files and outputs a detailed list of resources to be created, modified, or deleted. Importantly, it doesn't make any actual changes to infrastructure, instead helping identify potential issues before applying changes. The plan can be saved to a file for later execution or review. This command is crucial for reviewing changes before implementation, especially in complex environments, and is commonly used in code reviews and CI/CD pipelines to validate proposed infrastructure modifications. While terraform plan provides a preview, it's worth noting that it can't always predict every change due to external factors or API limitations.
Learn more from the following resources:
- [@course@Create a Terraform plan](https://developer.hashicorp.com/terraform/tutorials/cli/plan)
- [@video@Terraform - Terraform Plan](https://www.youtube.com/watch?v=9v08h-Oaelo)
- [@article@Terraform plan command and how it works](https://spacelift.io/blog/terraform-plan)

@ -1 +1,11 @@
# TFLint
TFLint is a third-party, extensible linter for Terraform code. It performs static analysis of Terraform configurations to detect potential errors, enforce best practices, and maintain code consistency. Key features include: Checking for potential errors that terraform validate might miss, enforcing naming conventions and code style rules, identifying deprecated syntax or resource types and, providing cloud provider-specific checks
TFLint is configurable via .tflint.hcl files and supports custom rules. It can be integrated into CI/CD pipelines for automated code quality checks. While not an official Terraform tool, TFLint is widely used in the Terraform community to complement built-in validation tools and improve overall code quality and reliability in infrastructure-as-code projects.
Learn more from the following resources:
- [@opensource@TFLint Documentation](https://github.com/terraform-linters/tflint)
- [@article@What is TFLint and How to Lint Your Terraform Code](https://spacelift.io/blog/what-is-tflint)
- [@video@Quick Tech - TFLint](https://www.youtube.com/watch?v=-BKWpI4Olpw)
Loading…
Cancel
Save