Table of Contents
This project is built to create an AMI that is pre-configured to host a PHP application in AWS EC2 instance.
The project is built using,
- AWS resources
- Packer
- Ansible
- Create a free tier AWS account.
- Create an IAM user with programmable access and make a note of the access and secret keys.
- Clone the repo
git clone https://github.com/listentolearn/aws-ami-builder-packer
- Install Packer
- Install Ansible
The AMI is created using packer.
- Set the environment vaiables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
- Update the default values of base_ami (amazon linux), subnet_id (with internet access) and security_group_id (allow port 22 from local ip) in the variables.pkr.hcl to match the ones in your AWS account.
- cd into the packer folder in the cloned repository.
- Run the following commands in order
- packer init .
- packer fmt .
- packer validate .
- packer build .
This will provision the AMI in you AWS account.
Now, you can use the AMI to launch an EC2 instance which will have the web application pre configured and ready to use.