What it is
AWS CodeDeploy automates application deployments to EC2 instances, on-premises servers, Lambda functions and Amazon ECS. An appspec file in the repository lists which files go where and which scripts run at each stage, such as before install, after install and validation. An agent on each server carries out the work.
CodeDeploy is often paired with CodePipeline, which watches a source repository and runs the stages from a commit to a release. Deployments can roll out in place or as blue/green, and a failed deployment can roll back automatically. Every deploy is recorded, so it is clear what is on each server and when it got there.
How I use it
- CodeCommit, CodePipeline and CodeDeploy: every push to main of the Rental Pilot API lands on the test server.
- Billing and asset cron jobs are installed through CodeDeploy, so staging matches production exactly.
- Production is a separate deploy script that refuses to run from anything but the tip of main with a clean tree.
- Deploy scripts lock, so two deploys never interleave.
CodeDeploy is the right tool when code lands on servers you run and every deploy should happen the same way. I use it for the test server so every push is exercised straight away, and keep production as a separate, deliberate step.
Questions
How do you deploy without breaking production?
Every push goes to a test server first through CodeDeploy, and production is a separate script that refuses to run from unpushed or uncommitted code.
Can a legacy PHP app use modern deploy pipelines?
Yes. Rental Pilot's PHP API deploys through CodePipeline and CodeDeploy on every push to main.