Terraform & Packer used to deploy infra in AWS.
- Install terraform
wget https://releases.hashicorp.com/terraform/0.10.8/terraform_0.10.8_linux_amd64.zip -O /tmp/terraform.zip
cd /tmp
unzip /tmp/terraform.zip
sudo install /tmp/terraform /usr/bin
- Install packer
wget https://releases.hashicorp.com/packer/1.1.1/packer_1.1.1_linux_amd64.zip -O /tmp/packer.zip
cd /tmp
unzip /tmp/packer.zip
sudo install /tmp/packer /usr/bin
- Set ssh key for keypair
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa.iac
- Set AWS credentials
export AWS_ACCESS_KEY_ID="<your access key>"
export AWS_SECRET_ACCESS_KEY="<your secret key>"
cd ami_web
packer validate ami_web.json
packer build ami_web.json
cd vpc
terraform init
terraform validate
terraform plan
terraform apply
cd ../ami_web
# Update vpc_id & subnet_id in ami_web/ami_web.json from value created in vpc
packer validate ami_web.json
packer build ami_web.json
cd ../web
terraform init
terraform validate
terraform plan
terraform apply
- Get AWS elb url and reload it to see each web VM