From d1a698447d43b822e30e15d0619a9802c873b288 Mon Sep 17 00:00:00 2001 From: dsh Date: Tue, 9 Jul 2024 13:09:34 +0100 Subject: [PATCH] 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 --------- Co-authored-by: Kamran Ahmed --- .../content/clean-up@inbTto9Qukdj6egRJ0Zh9.md | 8 ++++++- .../deployment@pjmOK1MEMnIV_zAlaOF01.md | 12 ++++++++++- .../format--validate@Xes24SqkwSaO844kLbClj.md | 15 ++++++++++++- .../output-syntax@31fa8kBzCEn-uCrTSoPM4.md | 21 ++++++++++++++++++- ...sensitive-outputs@8giL6H5944M2L0rwxjPso.md | 20 +++++++++++++++++- .../terraform-apply@LDpj-LY_SOXzno04D-Y25.md | 10 ++++++++- ...terraform-destroy@LPI13FILvkD55hWcWbPrV.md | 10 ++++++++- .../terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md | 10 ++++++++- .../terraform-plan@LDxAXmTKyvogvgUpvN5pT.md | 10 ++++++++- .../content/tflint@YftsQYpcqJqBKPjy5tWOq.md | 12 ++++++++++- 10 files changed, 118 insertions(+), 10 deletions(-) diff --git a/src/data/roadmaps/terraform/content/clean-up@inbTto9Qukdj6egRJ0Zh9.md b/src/data/roadmaps/terraform/content/clean-up@inbTto9Qukdj6egRJ0Zh9.md index 5e1c3a671..2e456bc99 100644 --- a/src/data/roadmaps/terraform/content/clean-up@inbTto9Qukdj6egRJ0Zh9.md +++ b/src/data/roadmaps/terraform/content/clean-up@inbTto9Qukdj6egRJ0Zh9.md @@ -1 +1,7 @@ -# Clean Up \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md b/src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md index 7a9e3e037..c2f3054de 100644 --- a/src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md +++ b/src/data/roadmaps/terraform/content/deployment@pjmOK1MEMnIV_zAlaOF01.md @@ -1 +1,11 @@ -# Deployment \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/format--validate@Xes24SqkwSaO844kLbClj.md b/src/data/roadmaps/terraform/content/format--validate@Xes24SqkwSaO844kLbClj.md index 558c38cf8..e14262e55 100644 --- a/src/data/roadmaps/terraform/content/format--validate@Xes24SqkwSaO844kLbClj.md +++ b/src/data/roadmaps/terraform/content/format--validate@Xes24SqkwSaO844kLbClj.md @@ -1 +1,14 @@ -# Format & Validate \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/output-syntax@31fa8kBzCEn-uCrTSoPM4.md b/src/data/roadmaps/terraform/content/output-syntax@31fa8kBzCEn-uCrTSoPM4.md index 04ef0d2e1..787a941be 100644 --- a/src/data/roadmaps/terraform/content/output-syntax@31fa8kBzCEn-uCrTSoPM4.md +++ b/src/data/roadmaps/terraform/content/output-syntax@31fa8kBzCEn-uCrTSoPM4.md @@ -1 +1,20 @@ -# Output Syntax \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/sensitive-outputs@8giL6H5944M2L0rwxjPso.md b/src/data/roadmaps/terraform/content/sensitive-outputs@8giL6H5944M2L0rwxjPso.md index 0f0e5f35f..6c80403bd 100644 --- a/src/data/roadmaps/terraform/content/sensitive-outputs@8giL6H5944M2L0rwxjPso.md +++ b/src/data/roadmaps/terraform/content/sensitive-outputs@8giL6H5944M2L0rwxjPso.md @@ -1 +1,19 @@ -# Sensitive Outputs \ No newline at end of file +# 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 "" 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/terraform-apply@LDpj-LY_SOXzno04D-Y25.md b/src/data/roadmaps/terraform/content/terraform-apply@LDpj-LY_SOXzno04D-Y25.md index 33952bace..ba54669b8 100644 --- a/src/data/roadmaps/terraform/content/terraform-apply@LDpj-LY_SOXzno04D-Y25.md +++ b/src/data/roadmaps/terraform/content/terraform-apply@LDpj-LY_SOXzno04D-Y25.md @@ -1 +1,9 @@ -# terraform apply \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/terraform-destroy@LPI13FILvkD55hWcWbPrV.md b/src/data/roadmaps/terraform/content/terraform-destroy@LPI13FILvkD55hWcWbPrV.md index 2e6660c07..548b61320 100644 --- a/src/data/roadmaps/terraform/content/terraform-destroy@LPI13FILvkD55hWcWbPrV.md +++ b/src/data/roadmaps/terraform/content/terraform-destroy@LPI13FILvkD55hWcWbPrV.md @@ -1 +1,9 @@ -# terraform destroy \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md b/src/data/roadmaps/terraform/content/terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md index 0b9a28922..13ca7bf6f 100644 --- a/src/data/roadmaps/terraform/content/terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md +++ b/src/data/roadmaps/terraform/content/terraform-fmt@78bGm8J5Y1I8H4qioOvWb.md @@ -1 +1,9 @@ -# terraform fmt \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/terraform-plan@LDxAXmTKyvogvgUpvN5pT.md b/src/data/roadmaps/terraform/content/terraform-plan@LDxAXmTKyvogvgUpvN5pT.md index e37929d9c..7da6faf8b 100644 --- a/src/data/roadmaps/terraform/content/terraform-plan@LDxAXmTKyvogvgUpvN5pT.md +++ b/src/data/roadmaps/terraform/content/terraform-plan@LDxAXmTKyvogvgUpvN5pT.md @@ -1 +1,9 @@ -# terraform plan \ No newline at end of file +# 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) \ No newline at end of file diff --git a/src/data/roadmaps/terraform/content/tflint@YftsQYpcqJqBKPjy5tWOq.md b/src/data/roadmaps/terraform/content/tflint@YftsQYpcqJqBKPjy5tWOq.md index 9dba2d1d3..ae9dbe67f 100644 --- a/src/data/roadmaps/terraform/content/tflint@YftsQYpcqJqBKPjy5tWOq.md +++ b/src/data/roadmaps/terraform/content/tflint@YftsQYpcqJqBKPjy5tWOq.md @@ -1 +1,11 @@ -# TFLint \ No newline at end of file +# 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) \ No newline at end of file