When our code is ready, the EC2 instance is up and running… The code is automatically built by CodeCommit - It’s a time to get our hands dirty and configure CodePipeline!

cd3

First, we need to create new IAM policy for CodeBuild, which allows on executions on AWS services. Go to AWS console, IAM -> Roles -> Create Role -> CodeDeploy -> Use Case CodeDeploy -> Permission will be applied automatically -> Name it as CodeDeployRole and save.

cd12

Go to AWS Console and open CodePipeline service dashboard. Click on Get started and start the configuration wizard. First, we need to name our pipeline. Let’s name it RPM-Deployment.

cd4

Next, select the source provider as AWS CodeCommit. Choose our repository from the list and select master branch. CodePipeline will automatically detect any changes to a repository using CloudWatch Events. You can change these options, but leave it default.

cd5

Next, select the build provider as AWS CodeBuild. Choose our previously created project and continue.

cd6

Time to configure CodeDeploy. Select deployment provider AWS CodeDeploy and click on “create a new one in AWS CodeDeploy”.

cd7

Name our application as MOTD, select compute platform EC2/On-premises. Name deployment group as EC2Managed.

cd8

Choose In-place deployment for deployment type. It’s just for the demo purpose.

cd9

In the environment configuration section, select Amazon EC2 instances. Then type the tag you created before, during EC2 provisioning. Your EC2 instance will appear in matching instance section. That’s why it was so important during the creation of EC2.

cd10

Do not enable load balancer - we use only one EC2 for the demo purpose.

Deployment configuration, select CodeDeployDefault.AllAtOnce. This is very important, as we have only one running instance!

cd11

Finally, select the service role created before for CodeDeploy (CodeDeployRole) and create an application.

cd13

Now go back to CodePipeline wizard and select newly created CodeDeploy application name and deployment group.

cd14

CodePipeline requires IAM role, which allows on interaction with other AWS services. Click on Create Role. IAM will automatically prepare the role for you. Name it as AWS-CodePipeline-Service and select in the wizard.

cd15

Review all the changes and create the pipeline. That’s all! Wasn’t it easy ??

You will see your pipeline in a nice graphical interface.

cd16

In the next post, I’m going to show you the CI/CD environment in action!

Thank you!