3-part series - (3) Create a CodePipeline pipeline and deploy the application on the instance
Tags: codedeploy, codepipeline, s3, ec2
Published: 2023-02-24 02:05:09

In this 3-part series on **Create and Deploy applications using CodeDeploy and CodePipeline with Amazon S3 bucket versioning enabled** -

In the **3rd article**, we will create a CodePipeline pipeline and deploy the application on the instance


**1st article**
- As a reference, please read my **[3-part series - (1) Launch an EC2 Instance, Install CodeDeploy Agent and upload App_Linux.zip file to version enabled S3 bucket](https://dev.to/awsmine/3-part-series-1-launch-an-ec2-instance-install-codedeploy-agent-and-upload-applinuxzip-file-to-version-enabled-s3-bucket-dhp)**

**2nd article**
- As a reference, please read my **[3-part series - (2) Create a CodeDeploy application and Deployment group](https://dev.to/aws-builders/3-part-series-2-create-a-codedeploy-application-and-deployment-group-47gk)**

_**Let’s get started!**_

Please visit my **[GitHub Repository for CI-CD/Docker/ECS/ECR articles](https://github.com/awsmine/Docker_projects)** on various topics being updated on constant basis.

# Objectives:

**1.** Create a CodePipeline pipeline and deploy the application on the instance

**2.** Test the application using EC2 Instance Public IPv4 DNS

**3.** Delete all the following services

# Pre-requisites:
- AWS user account with admin access, not a root account.
- AWS CLI.


# Resources Used:

**[CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html)**

**[CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html)**

**[CodeDeploy](https://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html)**

**[AWS CodePipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html)**



# Steps for implementation to this project


## 1. Create a CodePipeline pipeline and deploy the application on the instance


- **`on CodePipeline under Developer Tools, Pipelines, Create pipeline, my_codepipeline, Service role: New service role, AWSCodePipelineServiceRole-us-east-1-my_codepipeline, Next`**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t18ahirmh7mg92anp1nv.png)

**Add S3 policy to the role created by Codepipeline**

- **`On the IAM console, Roles, search and click for the role starting with AWSCodePipelineServiceRole-us-east-1-my-codepipeline which was created with the codepipeline, On the Permissions tab, Add permissions, Attach policies, Search and select AmazonS3FullAccess, Attach policies`**

- **`Expand the option of Advanced settings, Artifact store: Custom location, Bucket: codecommit-bucket12`**

- Next 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u1kx3n9x840b17doacb7.png)



**1.** Add Source stage

- **`Source provider : Choose Source provider: Amazon S3, Bucket: codecommit-bucket12, S3 object key: App_Linux.zip`**

- Next

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4mhxcuagcae0g4s5lpuf.png)

**2.** Add build stage

**`Skip build stage`**

- Next


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m39dj3vodpsfrowlaubi.png)

- **`Skip`**


**3.** Add deploy stage

**`Deploy provider : AWS CodeDeploy, Region: US East (N. Virginia), Application name: my-codedeployapp, Deployment group: my-codedeploy-grp`**

- Next



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kuu7s4yacquet1e3spvv.png)




- Review and Create Pipeline.


- CodePipeline has started to run and will succeed.

- Wait for 4-5 minutes to succeed


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5fz3i0v57lugi5zyl4c.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jjfhctig2vl3v7srvdn.png)


## 2. Test the application using EC2 Instance Public IPv4 DNS


- Copy the Public IPv4 DNS of the Instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f173mmbogfarirnwf3e0.png)


## 3. Delete all the following services

- EC2 Instance

- CodeDeploy Application

- CodePipeline

- AWSCodePipelineServiceRole-us-east-1-my_codepipeline

- S3 Bucket

- HTTPS Git credentials for AWS CodeCommit

# What we have done so far

- We have successfully created and deployed applications using CodeDeploy and CodePipeline with Amazon S3 bucket versioning enabled