Terraform: Difference between revisions
Jump to navigation
Jump to search
Line 134: | Line 134: | ||
| valign="top" | | | valign="top" | | ||
* [https:// | * [https://www.reddit.com/r/Terraform/comments/yxtq02/items_to_include_in_gitignore_when_using_a_cli/ Terraform » Items to include in <code>.gitignore</code>] | ||
* [https://developer.hashicorp.com/terraform/language/resources/behavior Terraform » Resources » Behavior] | * [https://developer.hashicorp.com/terraform/language/resources/behavior Terraform » Resources » Behavior] | ||
* [https://developer.hashicorp.com/terraform/language/resources/syntax Terraform » Resources » Blocks] | * [https://developer.hashicorp.com/terraform/language/resources/syntax Terraform » Resources » Blocks] | ||
Line 147: | Line 147: | ||
| valign="top" | | | valign="top" | | ||
* [https://stackoverflow.com/questions/67963719/ Terraform » <code>.terraform.lock.hcl</code> excluded from <code>.gitignore</code>] | * [https://stackoverflow.com/questions/67963719/ Terraform » <code>.terraform.lock.hcl</code> excluded from <code>.gitignore</code>] | ||
* [https:// | * [https://medium.com/@arnobroekhof/using-sonatype-nexus-3-as-backend-provider-for-terraform-41e16d275fd7 Terraform » TFState » Sonatype Nexus 3] | ||
* [https://spacelift.io/blog/gitlab-terraform-state Terraform » TFState » Sapcelift » GitLab] | * [https://spacelift.io/blog/gitlab-terraform-state Terraform » TFState » Sapcelift » GitLab] | ||
* [https://developer.hashicorp.com/terraform/language/settings/backends/configuration Terraform » Backend » Configuration] | * [https://developer.hashicorp.com/terraform/language/settings/backends/configuration Terraform » Backend » Configuration] |
Revision as of 18:05, 17 July 2024
curl -fsSL https://apt.releases.hashicorp.com/gpg\
| sudo tee /etc/apt/keyrings/hashicorp.asc >/dev/null
cat << EOF | sudo tee /etc/apt/sources.list.d/hashicorp.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/hashicorp.asc]\
https://apt.releases.hashicorp.com $(lsb_release -cs) main
EOF
sudo apt update && sudo apt list --upgradeable
sudo apt upgrade && sudo apt install terraform
terraform version
Structure
sdlc/
├─ main.tf # Main Terraform config file
├─ variables.tf # Variable declarations
├─ terraform.tfvars # Variable assigned
├─ outputs.tf # Output definitions
├─ provider.tf # Provider-specific config
├─ terraform.tfstate # Terraform state file
├─ dev.tf # Dev Env config for development
├─ prod.tf # Prod Env config for production
├─ modules/ # Directory for custom modules
│ ├─ module1/ # Custom module 1
│ │ ├─ main.tf # Module-specific Terraform config
│ │ ├─ variables.tf # Module-specific variables
│ │ └─ outputs.tf # Module-specific outputs
│ └─ module2/ # Custom module 2
│ ├─ main.tf
│ ├─ variables.tf
│ └─ outputs.tf
├─ environments/ # Directory for env
│ ├─ dev/ # Development env
│ │ ├─ main.tf # Env specific Terraform config
│ │ ├─ variables.tf
│ │ └─ outputs.tf
│ └─ prod/ # Production env
│ ├─ main.tf
│ ├─ variables.tf
│ └─ outputs.tf
├─ scripts/ # Scripts or utility for IaC
└── README.md
Summary
Playground
References |