This project contains Terraform code for testing AWS infrastructure deployment with actual cost implications. Warning: Running this example code will incur actual costs in AWS.
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt update && sudo apt install unzip -y
unzip awscliv2.zip
sudo ./aws/install
rm -rf ./awsbrew install awscliaws --version
Ubuntusudo apt update && sudo apt install -y gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform -ybrew tap hashicorp/tap
brew install hashicorp/tap/terraformterraform --versionSet up AWS CLI configuration:
aws configureYou will need to provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name (e.g., ap-northeast-2)
- Default output format (json recommended)
-
Navigate to the desired environment directory
-
Set up your variables file:
cp variables.tf.sample variables.tfThen edit variables.tf with your specific configuration values
- Initialize Terraform
terraform init- Review the execution plan
terraform plan- Apply the infrastructure changes
terraform apply- Destroy infrastructure (when needed)
terraform destroy- Be aware that using these resources may incur actual AWS costs
- Always destroy unused resources to avoid unnecessary charges
- Never commit AWS credentials to version control
- Ensure sensitive files are properly listed in
.gitignore - Review and understand the infrastructure changes before applying them