Skip to content

codecommit,codebuild and codedeploy is used . and code pipeline is used to automate the entire pipeline

License

Notifications You must be signed in to change notification settings

PranitRout07/AWS-Codepipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

AWS-Codepipeline

AWS CodeCommit

  1. Created a codecommit repository .
create repo on code commit 2. Copied the repository URL . copy the repo url 3. Tried to git clone using the copied URL in local editor's terminal , but a screen appeared asking for git credentials . now try to git clone at local with copied url but a git credential it will ask 4. Created git credential for the IAM user role create git credentials
  1. After entering git credentials , i successfully cloned the repository .
git credentials
  1. Created a index.html file and pushed the ffile into codecommit repository .
created and pushed the index html to the repo

AWS CodeBuild

  1. CodeBuild stage needs a buildspec.yml file . So created a buildspec.yml file and pushed it to codecommit repo .
add buildspec yml to repo as it is needed during code build
  version : 0.2

  phases:
    install:
      commands:
        - echo Start with NGINX install
        - sudo apt-get update
        - sudo apt-get install nginx -y
    build:
      commands:
        - echo Building...
        - cp index.html /var/www/html/
  artifacts:
    files:
      - /var/www/html/index.html
  1. Then created a build .
codebuild.1.mp4

10 . After this i have to store artifacts , so i created a s3 bucket . Then attached the artifacts to the codebuild stage .

Screenshot 2024-01-11 153949 mention folder name
  1. Then started building .
build successful

AWS CodeDeploy

  1. Created an application on CodeDeploy
create application
  1. Created an EC2 insatnce with ssh,http,https added in security group . As the ec2 insatnce needs to interact with s3 bucket , codedeploy , ec2 ,so attached the policies .
ec2 policy
  1. Created a IAM role for deployment group with certain policies . policy attached (2)

  2. Then created deployment group .

create.deployment.group.1.mp4
  1. Then connected the ec2 instance to create codedeploy agent .
#!/bin/bash 
# This installs the CodeDeploy agent and its prerequisites on Ubuntu 22.04.  
sudo apt-get update 
sudo apt-get install ruby-full ruby-webrick wget -y 
cd /tmp 
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/releases/codedeploy-agent_1.3.2-1902_all.deb 
mkdir codedeploy-agent_1.3.2-1902_ubuntu22 
dpkg-deb -R codedeploy-agent_1.3.2-1902_all.deb codedeploy-agent_1.3.2-1902_ubuntu22 
sed 's/Depends:.*/Depends:ruby3.0/' -i ./codedeploy-agent_1.3.2-1902_ubuntu22/DEBIAN/control 
dpkg-deb -b codedeploy-agent_1.3.2-1902_ubuntu22/ 
sudo dpkg -i codedeploy-agent_1.3.2-1902_ubuntu22.deb 
systemctl list-units --type=service | grep codedeploy 
sudo service codedeploy-agent status

codedeploy running
  1. Like CodeBuild stage , CodeDeploy also needs a appspec.yml for configuration and in buildspec.yml changed the artifacts files . After making all these changes then pushed the code to the codecoommit repository .

appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html
hooks:
  AfterInstall:
    - location: scripts/install_nginx_service.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: scripts/start_nginx_service.sh
      timeout: 300
      runas: root

install_nginx_service.sh

#!/bin/bash

sudo apt-get update
sudo apt-get install -y nginx

start_nginx_service.sh

#!/bin/bash

sudo service nginx start
added appspec yml

builspec.yml changed buildspec to solve error

  1. Then created a deployment using revise location as s3 bucket's URL .
Screenshot 2024-01-11 165954
  1. After this i have checked whether all the files present in CodeCommit repo or not . Then again started the code build stage . Then started the deployment .
deployment suceeded
  1. After successful deployment then accessed the Public IP of ec2 instance to access the webpage .
after deployment succefully accessed

AWS CodePipeline

  1. Created a pipeline
create pipeline
  1. Added the code source and choosed "AWS CodePipeline" in "change detection option" to
code source provider

23.Here mentioned the build provider and project name .

build
  1. Now mentioned the AWS CodeDeploy as deploy provider and also give the application name .
deployment
  1. Now after all these configuartion , here i started the AWS CodePipeline . And all the stages are successfully executed.
pipeline succeded
  1. Then accessed webpage using public ip of ec2 instance .
after deployment succefully accessed
  1. Then made some changes in the index.html and pushed the changes into codecommit repo .
index html file code is updated
  1. Then pipeline is automatically started .
look here the message also updated
  1. Then accessed the updated webpage from the public IP of ec2 instance .

About

codecommit,codebuild and codedeploy is used . and code pipeline is used to automate the entire pipeline

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published