AWS Code Commit and Code Deploy and Code Pipeline creation step by step
Step:1 Prerequisites
- Download and install Git on you local system(Linux and Windows)
- Configure GIT on your system
- git config --global user.email (git config --global user.email cloudsunilpatel@gmail.com)
- git config --global user.name "your name" (git config --global user.name "Sunil Kumar Patel")
- Create New AWS IAM user Or use existing admin user (User Name:SunilCode)
a. Attach IAM policy "AWScodecommitFullAccess"
b. Attach IAM policy "AWScodePipelineFullAccess"
c. Security Credentials -->> HTTPS Git Credentials -->>Generate and Save the credentials file
- Create Service Role for CodeDeploy (Role Name:AWSCodeDeployRole)
a. Create IAM role for CodeDeploy service
b. Attach existing IAM policy "AWSCodeDeployRole"
- Create IAM Role for Ec2 to download logs from S3 (Role Name:Name:AmazonS3readonlyAccess)
a. Create IAM role for EC2 service to attach "AmazonS3readonlyAccess" policy
Step:2 Configure CodeCommit Respository
- Go to CodeCommit Service (Use North Virginia Region )
- Create new code repository with name "Demo-project"
- Copy the Clone URL >>Clone HTTPS (https://git-codecommit.ap-south-1.amazonaws.com/v1/repos/Demo-project)
- Clone Git Repository locally
- Git clone
- Provide username/Password (This should create empty repository)
This is assuming your authenticating with IAM roles. If you are add the default AWSCodeCommitReadOnly policy then you can be sure that you can rule out IAM policies. The supplied commands:git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
- Download Sample Application
- Download application locally
- Unzip and move all files and folders inside your local repository "Demo-project" directory
- Change your CMD to Demo-Project
- git status
- Git add -A
- Git commit -m "Added sample application files"
- Git push
Step:3 Launch EC2 instance to Host Application
- Launch EC2 instance with below requirements
- AMI: Amazon Linux 2
- Instance Type: T2 Micro
- VPC: Default
- IAM Role: Role that we created in Step #1
- In Advance option , Paste the below user data to install CodeDeploy Agent
#!/bin/bash sudo yum update -y sudo yum install ruby -y sudo yum install awscli -y cd /home/ec2-user aws s3 cp s3://aws-codedeploy-ap-south-1/latest/install . --region ap-south-1 chmod +X ./install ./install auto |
#!/bin/bash sudo apt update sudo apt install ruby sudo apt install awscli cd /home/ubuntu aws s3 cp s3://aws-codedeploy-ap-south-1/latest/install . --region ap-south-1 chmod +X ./install ./install auto |
- Tags: Key: Name, Value: Demo
- Security Group: Open Port no # 22 and 80 for my IP or Internet
- SSH keypair: use existing keypair
- Launch
Step:4 Create Application in Code Deploy
- Go to CodeDeploy service
- Create New Application
- Name:Demo
- Compute Platform: Ec2/On-premises
- Create Application
- Deployment Groups
- Name: Demo-Group
- Deployment Type:In-place Deployment
- Environment configuration :
- Amazon EC2 Instances
- Enter the Key=Name and Value=Demo (That you created while launching EC2 instance)
- Deployment Configurtion
- Select CodeDeployDefault.OneAtaTime
Step:5 Create CodePipeLine
- Go to AWS CodePipeline service
- Create Pipeline
- Name:Demo-Pipeline
- Service Role: New Service Role
- Artifact Store: Default
- Add Source Stage
- Source Provider : AWS CodeCommit
- Repository: Select your Repository "Demo-project"
- Branch: Select Master branch
- Detection Option: Select CloudWatch Events
- Add Build stage -->SKIP
- Add Deploy Stage
- Deploy Provider: AWS CodeDeploy
- Application Name: Demo (This you had created in previous Step #4)
- Deployment Group: Demo-Group (This you had created in previous Step #4)
No Comments Yet!!