Terraform: Difference between revisions
Jump to navigation
Jump to search
Line 105: | Line 105: | ||
terraform apply | terraform apply | ||
terraform destroy | terraform destroy | ||
</syntaxhighlight> | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
cat << INI | tee -a ${HOME}/.aws/config | |||
[default] | |||
region = ap-southeast-1 | |||
output = table | |||
INI | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
cat << INI | tee -a ${HOME}/.aws/credentials | |||
[academia] | |||
aws_access_key_id = AKIBVWTF7RISAULV8Q6Q | |||
aws_secret_access_key = w2JVkDIE9zRTIP/S4m7Mm4cWKlFEYlzg1iGzfCnj | |||
INI | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
cat << INI | tee -a ${HOME}/.aws/config | |||
[profile academia] | |||
region = ap-southeast-1 | |||
output = json | |||
INI | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 116: | Line 150: | ||
export AWS_PROFILE=academia | export AWS_PROFILE=academia | ||
cat ~/.aws/credentials | cat ~/.aws/credentials | ||
aws ec2 describe-vpcs | |||
cat ~/.aws/config | cat ~/.aws/config | ||
aws s3 ls | aws s3 ls |
Revision as of 04:25, 18 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 |