Application development is comprised of different stages. One such critical step is app deployment and code management. In this article, we’re going to share how you can use a deployment system that will enable you to automate the deployment and updating of your application – AWS CodeDeploy. It’s one of the three AWS tools which will help you integrate, deploy, and manage your app on the cloud: CodeDeploy, CodeCommit, and CodePipeline.
AWS CodeDeploy is deployment system that enables a developer or a team of developers to automate the software release process. In other words, it is a collection of settings that relates to the environment on which the application is to be deployed, how many instances can be implemented at once, and so on. It efficiently deploys your code to a fleet of EC2 instances while leaving as much of the fleet online as possible. The size of a fleet can vary from a single instance to thousands of instances.
The first step to getting started with AWS Code deploys is setting up EC2 instances. Then, you’ll need to tag them – this will allow you to define deployment groups, install the CodeDeploy agent on your hosts, and set up trust-roles to allow communication between the CodeDeploy and CodeDeploy agents.
CodeDeploy also specifies information regarding the trusted role which automates the communication between the various EC2 instances and CodeDeploy. However, CodeDeploy doesn’t specify the code to be deployed or what to do during the deployment. The code to be implemented is stored as an archive in S3 and is referred to as an Application Revision. The “how to deploy” component of CodeDeploy is specified by the AppSpec file located inside the Application Revision. Here’s what you need to know about them:
Since you will have one application in your repo when you package up the entire repo, you can then create your Application Revision (excluding the .git). When you do this, appsec.yml needs to be replaced in your repo root directory.
Now that we’ve learned what CodeDeploy is and established how it works, let’s move on to the steps which will show you how to deploy an application from GitHub with AWS CodeDeploy.
Now over the GitHub home page, perform either of the subsequent steps:
Over the Repository name box, type CodeDeployGitHubDemo. Choose Public. Remove Initialize this repository with README check box. You need to create a README.md file in the following step. Select Create repository Now, after creating a repository, you will need to follow the following instruction for using the command line. These guidelines differ from the operating system you're using:
For Unix or Linux: From the terminal, you need to run the below-mentioned commands, in sequence, where the username will be your GitHub username.
mkdir /tmp/CodeDeployGitHubDemo cd /tmp/CodeDeployGitHubDemo touch README.md git init git add README.md git commit -m "My first commit" git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git git push -u origin master
You should then leave the command prompt open in the /tmp/CodeDeployGitHubDemo location.
For Windows: As an administrator, from the command prompt, run the following commands, in sequence:
mkdir c:\temp\CodeDeployGitHubDemocd c:\temp\CodeDeployGitHubDemonotepad README.md
Now, in the notepad save the README.md file. Close the notepad. Run the following commands, in sequence, where again the username will be your GitHub username:
git init git add README.md git commit -m "My first commit" git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git git push -u origin master
Then leave the command prompt open in the /tmp/CodeDeployGitHubDemo location.
Over the Application details page, in Deployment groups, select the button next to CodeDeployGitHubDemo-DepGrp.
In the Actions menu, select Deploy New Revision.
Over the Create New Deployment page, in the Revision Type area, select My application is stored in GitHub.
Select Connect with GitHub. The page which appears will ask you to authorize AWS CodeDeploy for interacting with GitHub for the application known as CodeDeployGitHubDemo-App.
Shadow the instructions over the Sign in the page to sign in with the GitHub account.
Now, on the Authorize application page, select Authorize Application.
On the AWS CodeDeploy Create New Deployment page, in the Repository Name box, key in the GitHub username which you had used while signing in, followed by a forward slash (/), followed by the name of the repository where you pushed your application revision (for instance, My-GitHub-User-Name/CodeDeployGitHubDemo)
If you are not sure about value to type, or if you need to specify a different repository:
Over the Commit ID box, key in the ID of the commit associated with the push of your application revision to GitHub.
If you are not sure of the value to type:
Leave the Deployment Description box blank.
Leave the Deployment Config drop-down list at the default of CodeDeployDefault.OneAtATime,
and select Deploy Now.
You now know how to deploy an application with GitHub and AWS CodeDeploy. If you have any questions, be sure to leave a comment below. For more information about CodeDeploy and other development best practices on AWS, take a look at our Developer Fundamentals for AWS course. It’s jam-packed with information about CodeDeploy, CodeCommit, and CodePipeline.
Reference: Tutorial: Deploy an Application from GitHub Using AWS … (n.d.). Retrieved from http://docs.aws.amazon.com/codedeploy/latest/userguide/github-integ-tutorial.htm.
It's Flash Sale time! Get 50% off your first year with Cloud Academy: all access to AWS, Azure, and Cloud…
In this blog post, we're going to answer some questions you might have about the new AWS Certified Data Engineer…
This is my 3rd and final post of this series ‘Navigating the Vocabulary of Gen AI’. If you would like…