AWS OpsWorks custom layer with support for PHP 7.4 and php application deployment from a private git repository. The project also contains an Amazon Linux virtual machine using Vagrant that emulate Amazon Linux AMI environment.
Please make sure to read opsworks user guide before using these cookbooks http://docs.aws.amazon.com/opsworks/latest/userguide/chef-12-linux.html
Based on https://www.chef.io/blog/2015/12/07/chef-community-cookbooks-with-aws-opsworks-chef-12/
- Chef Development Kit (chefdk)
- AWS CLI
- S3 bucket for chef cookbooks deployment
- Vagrant
- Download or clone this repository
- Run
berks package cookbooks.tar.gz
to bundle the cookbooks - Upload cookbooks bundle to S3
aws s3 cp cookbooks.tar.gz s3://YOURBUCKET/cookbooks.tar.gz
- Add a new stack (Chef 12 Stack)
- Use latest Amazon Linux AMI
- Under Advanced Settings:
- Pick
Use custom Chef cookbooks
- Repository type:
S3 Archive
- Repository URL
s3://YOURBUCKET/cookbooks.tar.gz
- Enter S3 credentials if your cookbooks are not public
- Pick
- Add a new layer.
- Edit the newly created layer, and add the custom chef recipes:
- add phpapp::setup_opsworks to the setup lifetime event
- add phpapp::deploy_opsworks to the deploy lifetime event
- If your VPC is public, make sure the Automatically
Assign Public IP Address
in the layer's network settings is turned on - Add an application from the "Applications" section. Make sure to enter your git deploy key
- Download Vagrant 2.2+ from http://www.vagrantup.com
- Download the latest VirtualBox from https://www.virtualbox.org
- Install ChefDK 4+ https://downloads.getchef.com/chef-dk/mac/#/
- Create a new project with the supplied
Vagrantfile
and editchef.cookbooks_path
to point to the cookbooks folder - Run
sudo berks vendor resolved-cookbooks
to bundle the cookbooks - Run
sudo vagrant up
to start the virtual machine