Terraform: Difference between revisions
Jump to navigation
Jump to search
Line 88: | Line 88: | ||
==Backend » HTTP== | ==Backend » HTTP== | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cat << HCL | tee -a ./backend.tf >/dev/null | |||
cat << HCL | tee -a ./backend.tf | |||
terraform { | terraform { | ||
backend "http" { | backend "http" { | ||
} | } | ||
} | } | ||
Line 130: | Line 97: | ||
---- | ---- | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cat << HCL | tee -a ./ | cat << HCL | tee -a ./gitlab.http.tfbackend >/dev/null | ||
unlock_address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke/unlock" | |||
lock_address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke/lock" | |||
address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke" | |||
username = "academia" | |||
password = "sadaqah!" | |||
unlock_method = DELETE | |||
lock_method = POST | |||
retry_wait_min = 5 | |||
HCL | HCL | ||
</syntaxhighlight> | </syntaxhighlight> | ||
---- | ---- | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cat << HCL | tee -a ./ | cat << HCL | tee -a ./nexus.http.tfbackend >/dev/null | ||
unlock_address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke/unlock" | |||
lock_address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke/lock" | |||
address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke" | |||
username = "[email protected]" | |||
password = "sadaqah!" | |||
unlock_method = DELETE | |||
lock_method = POST | |||
retry_wait_min = 5 | |||
HCL | HCL | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:59, 21 July 2024
curl -fsSL https://apt.releases.hashicorp.com/gpg\
| sudo tee /etc/apt/keyrings/hashicorp.asc >/dev/null
cat << SRC | 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
SRC
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
├─ academia.auto.tfvars # User Sensitive Data
├─ 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
Backend » HTTPcat << HCL | tee -a ./backend.tf >/dev/null
terraform {
backend "http" {
}
}
HCL
cat << HCL | tee -a ./gitlab.http.tfbackend >/dev/null
unlock_address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke/unlock"
lock_address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke/lock"
address = "https://gitlab.chorke.org/api/v4/projects/123/terraform/state/aws-chorke"
username = "academia"
password = "sadaqah!"
unlock_method = DELETE
lock_method = POST
retry_wait_min = 5
HCL
cat << HCL | tee -a ./nexus.http.tfbackend >/dev/null
unlock_address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke/unlock"
lock_address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke/lock"
address = "https://nexus.chorke.org/repository/terraform/chorke-sdlc/state/aws-chorke"
username = "[email protected]"
password = "sadaqah!"
unlock_method = DELETE
lock_method = POST
retry_wait_min = 5
HCL
Playground
References |