Aws Ci

Gopinath JGopinath J
4 min read

AWS offers CI/CD tools like AWS CodeCommit, AWS CodePipeline, AWS CodeBuild and AWS CodeDeploy. These tools allows to automate the entire software release process, from source code management to deployment.

AWS CodeCommit - It is a managed source control service. It works similar to git and has most of the features that github have.

AWS CodePipeline - It is a continuous Integration/ continuous Deployment service that automates build, test and deploy phases.

AWS CodeBuild - It is used to run test cases, build our application and gives deployable files. It automates the building phase of our application.

AWS CodeDeploy - It is a deployment service that automates the deployment of the application to various sources like AWS EC2,AWS ECS or AWS Lambda.

In this, we are going to implement Continuous Integration of flask application using Github, AWS CodeBuild and AWS CodePipeline.

  1. Create the repo in github for continuous Integration.

  2. Go to AWS console -> Code Build and select Create project.

  3. Enter the project name and source.

Source - It defines where to take the code from. It has codeCommit, GitLab,etc., We are using github.

Repository - Select connect using OAuth and connect your github account to AWS.

  1. Once you have connected, it will ask the repository to connect.

  2. Enter the Environment

Environment - It refers to the combination of operating system and tools that CodeBuild uses to run your build process.

  1. Select the role.

If you want to create a role, You need to give SSM access and attach the role to it.

  1. In Advanced Settings, Enable the privileged if you want to build images.

  2. Specify the build commands in BuildSpec section.

In build Commands, We cannot specify the passwords as it can be seen by anyone.So, we should specify the confidentials datas in parameter store of system manager and use their keys here like I used Username,Passwords.

Parameter Store :

i) Search Parameter Store in AWS Console -> Enter into it -> Create Parameter.

Name - Enter the parameter name which is key to retrieve value.

Type - Parameters supports different types,

  • String - It is used to store a single string value. It is used to store database connections.

  • Stringlist - It stores list of strings seperated by comma. It is used to store environment variables.

  • SecureString - It is used to store sensitive informations like passwords. It is encrypted using AWS KMS (Key Management Service).

ii) Provide the value here and select create parameter.

  1. Once the above configurations are done, select the create Build and the build looks like this, Select start build option to start building the project manually.

  2. When the project is built successfully, It will look similar to this,

  1. You can verify if the image is pushed to docker hub.

    I can see that my image is pushed into dockerhub.

  2. Now we need to integrate CodePipeline with CodeBuild. Go to CodePipeline -> Select create Pipeline.

  3. Enter the pipeline settings.

  4. Enter the source details.

  5. Enter details for build stage.

  6. As of now we are not using CD, so skip deploy stage and select create pipeline.

  7. Now the pipeline is starting

  8. After source is success, Build stage will start.

  9. Now both have succeeded.

  10. Now modify something to our github files and check if the CI is executing automatically.

    I have modified some spaces in app.py of my github repo.

  11. Commit the changes.

  12. As soon as we commit our changes, the source is again In progress.

    Build Success - It shows the previous successful build. It will be In progress when Source is succeeded.

  13. Now source is succeeded, Build is In progress.

  14. Now both of them are succeeded.

Conclusion :

We have successfully implemented continuous integration using AWS CI/CD tools.

0
Subscribe to my newsletter

Read articles from Gopinath J directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gopinath J
Gopinath J