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!
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.
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.
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.
Next, select the build provider as AWS CodeBuild. Choose our previously created project and continue.
Time to configure CodeDeploy. Select deployment provider AWS CodeDeploy and click on “create a new one in AWS CodeDeploy”.
Name our application as MOTD, select compute platform EC2/On-premises. Name deployment group as EC2Managed.
Choose In-place deployment for deployment type. It’s just for the demo purpose.
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.
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!
Finally, select the service role created before for CodeDeploy (CodeDeployRole) and create an application.
Now go back to CodePipeline wizard and select newly created CodeDeploy application name and deployment group.
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.
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.
In the next post, I’m going to show you the CI/CD environment in action!