Basic CI, CD Setup using AWS — CodeCommit, CodePipeline, & Elastic Beanstalk as deploy provider.

Santhosh S
4 min readFeb 7, 2021

In this article, we’ll be setting up a simple (nothing fancy) CI, CD setup using AWS — CodeCommit, CodePipeline & CodeDeploy. I’ll be assuming that you have a basic idea about what is CI, CD and basic services of AWS. To make it simple we are skipping the CodeBuild step which is used for Test & Build the packages that are ready to deploy.

AWS CodeCommit:

CodeCommit is a fully-managed source control service that hosts secure Git-based repositories. It makes it easy for teams to collaborate on code in a secure and highly scalable ecosystem. CodeCommit eliminates the need to operate your own source control system or worry about scaling its infrastructure. You can use CodeCommit to securely store anything from source code to binaries, and it works seamlessly with your existing Git tools.

In short — It is like GitHub with more or less similar features. To know more about CodeCommit — https://aws.amazon.com/codecommit/

AWS CodePipeline:

CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software. CodePipeline automates the steps required to release your software changes continuously using different stages. We can customize the stages based on our need like Build, Test, Deploy. To know more about CodePipline — https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html

Elastic Beanstalk:

Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications. services developed with Java, .NET, PHP, Node.js, Python, etc. You can simply upload your code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto-scaling to application health monitoring. To know more about Elastic Beanstalk: https://aws.amazon.com/elasticbeanstalk/

Lets start the steps to create CI, CD setup :

Step 1: Search and open CodeCommit service in AWS console. Create a repository by giving a name — Add Tags & Description, if u want.

Step 2: Pushing the code to repository — am using GUI to push the code into repository (Not recommended), you can use CLI to push and pull code, just like GitHub. If you use root account you cannot use SSH connections for a root account, even HTTPS is not recommended with root, always use a user with less privileges.

Am uploading the simple node.js code using GUI which I already downloaded from https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/samples/nodejs.zip.

Click on upload & choose file to upload your code from your local workspace.

Your file will uploaded to your repository with a commit id just like GitHub. Push all the files.

Step 3: After creating repository next step is to create a pipeline to deploy our code into Elastic Beanstalk using CodePipeline. Search & open CodePipeline service.

CodePipeline > Create Pipeline & give a name to pipeline, leave the other option default ( It will create new role for CodePipeline, if you have existing role, you can attach it. Otherwise leave it default) > Click Next

In advanced setting you can specify a S3 Bucket for artifact location. If you don’t want to specify, it will create one. Also you can specify encryption method, either default managed key or using customer managed key.

In next step select the source for the code, in our case its CodeCommit. You can use other options like S3, Bitbucket, etc. as a source. Then choose the repository name and select the branch, in our case its main branch. Leave the other options as default, it is for change detection in our repository & Output artifact format. >> Click Next.

Skip Build Stage: ***Skip the build step by clicking skip build stage and click confirm.***

Step 4: In deploy stage select Elastic Beanstalk as a deploy provider & Choose the region you want to deploy & choose the application name and environment which is already created in Elastic Beanstalk — am not going to that. I already have an environment.

If you don’t have any environment, create one.

To create a new environment: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.environments.html

Click Next and review your pipeline and create. Done !

Now get your app URL from Elastic Beanstalk environment . Open in Browser You can see your page.

Lets change the content of our code it will automatically detect the change and deploy it to our EB environment.

Am changing the content “Congratulation” to “Congratulation Team We’ve done it” . It will trigger the pipeline now.

After the Pipeline execution completed, we can see our new content.

Done !!!!!

--

--