- Packer
- Ansible
- AWS
- Terraform
- Bash Script
- Nginx
- Make
- Install Packer via this link.
- Install Terraform via this link.
- (Needed by Packer)Set your aws credentials via environment variable with following keynames:
- ACCESS_KEY
- SECRET_KEY
- (Optional)Install Make via this link or use repository for *nix operating system.
- Change the current directory to packer and run following commands:
- packer validate nginx_web_server.json
- packer validate app_server.json
- Next step is to build the AMI if the validation is successful
- packer build nginx_web_server.json
- packer build app_server.json Note: This process will take time as it will provision a temporary EC2 instance, install Ansible on it, use Ansible to configure the image and then tag that image and store it in AWS.
- (Needed by Terraform) Make sure that your aws cli is installed and is configured with the credentials using "aws configure" command.
- Change the directory to respective deployment and run following commands, usually the order should be like below for first time.
- common-blue-green
- blue(for live production infrastructure)
- green(for the latest updated version of app and/or infrastructure, when needed)
- Change your directory to terraform and run below command to initiate the terraform:
- terraform init
- Run below command to plan your infrastructure:
- terraform plan
- After planning is successful, run the below command to provision the infrastructre: - terraform apply
- If you want to delete all the provisioned infrastructure run below command:
- terraform destroy
Note: This terraform configuration saves the terraform state to a remote s3 bucket. Make sure to change the name of bucket in ~/terraform/main.tf file and as well as make sure that you have IAM policy assigned to access the S3/bucket or cross check the bucket policies.
- make build
Note: Given that you have installed Packer, Terraform and configured the environment keys as well as aws cli.