Connect CodeDeploy to Github. Push to Master branch with git and the full solution will be automatically deployed to AWS.
📚 🚀 Amazon tutorials:
- What Is AWS CodeDeploy?
- Automatically Deploy from GitHub Using AWS CodeDeploy
- Tutorial: Use AWS CodeDeploy to Deploy an Application from GitHub
CodeDeploy is an Amazon Web Service that makes it easy to deploy code to EC2 instances. Github is going to notify CodeDeploy when there is a push to a repo and CodeDeploy will grab the latest changes.
🐙 🐈 Github
You must have a Github account! Create a new Github repository:
We are going to pull in a sample repository that Amazon is hosting on AWS S3. Head into the terminal and whatever directory you store code or projects. Run the following commands:
$ mkdir deploy-to-gitub
$ cd deploy-to-gitub
$ curl -O http://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Linux.zip
$ unzip SampleApp_Linux.zip
$ rm SampleApp_Linux.zip
$ lsLICENSE.txt appspec.yml index.html scripts
As you can see, this brings in some starter files from the AWS project and drops them into our repo. Add them to git and push them to the git repository we created:
$ git init
$ git add -A
$ git commit -m 'omg first commit'
$ git remote add origin https://github.com/connor11528/deploy-to-github.git
$ git push origin master
$ git status
The files from your local machine now show up in that repo on github.com! The sample code is available here (give it a ⭐ if you like).
💻 📡 AWS CodeDeploy
In AWS world we have EC2 (Elactic Cloud Compute) instances. Those are our servers and virtual machines in the cloud. We are going to use In-place deployment. In an in-place deployment, CodeDeploy reads the code from our appspec.yml file. The App Spec (appspec.yml) file is important because it defines the deployment actions we want AWS CodeDeploy to execute.
We then supply information about our Github repo to CodeDeploy. In AWS CodeDeploy a set of EC2 instances and Auto Scaling groups are called deployment groups. Each time we push to Github CodeDeploy will push the new code revisions to our specified deployment groups.
We want to automate our deployments so that whenever we git push to the master branch on Github our app automatically deploys to the internet and AWS.
Create an IAM user with the appropriate permissions
Set up an IAM user that has permissions to work with CodeDeploy.
If you have an existing IAM user that you use you can add the
Set up integration with CodeDeploy
Select CodeDeploy on your Github repo