How to upate simple HTML files via AWS – Code pipeline

CICD using code pipeline

CodeCommit::

Step:1

  • Create repository in codecommit-AWS (AWS-repo)
  • Push below code from local machine to codecommit::

 

|test

|– appspec.yml

|– index.html

|– LICENSE.txt

|– scripts

|– install_dependencies

|– start_server

|– stop_server

  • Install_dependencies script would be like below

  • Start_server script would be like below

  • Stop_server script would be like below

  • appsec.yml file would be like below

Step:2

  • Create EC2 instance to deploy application:
  • Create IAM role to attach EC2
  • Install Apache and AWS-CLI
  • Install Codedeploy agent using following steps:
  • bucket-name represents one of the following:
  • aws-codedeploy-us-east-2 for instances in the US East (Ohio) region
  • aws-codedeploy-us-east-1 for instances in the US East (N. Virginia) region
  • aws-codedeploy-us-west-1 for instances in the US West (N. California) region
  • aws-codedeploy-us-west-2 for instances in the US West (Oregon) region
  • aws-codedeploy-ca-central-1 for instances in the Canada (Central) region
  • aws-codedeploy-eu-west-1 for instances in the EU (Ireland) region
  • aws-codedeploy-eu-west-2 for instances in the EU (London) region
  • aws-codedeploy-eu-central-1 for instances in the EU (Frankfurt) region
  • aws-codedeploy-ap-northeast-1 for instances in the Asia Pacific (Tokyo) region
  • aws-codedeploy-ap-northeast-2 for instances in the Asia Pacific (Seoul) region
  • aws-codedeploy-ap-southeast-1 for instances in the Asia Pacific (Singapore) region
  • aws-codedeploy-ap-southeast-2 for instances in the Asia Pacific (Sydney) region
  • aws-codedeploy-ap-south-1 for instances in the Asia Pacific (Mumbai) region
  • aws-codedeploy-sa-east-1 for instances in the South America (São Paulo) region
  • aws-codedeploy-cn-north-1 for instances in the China (Beijing) region

Step:3

Go to CodeDeploy console and follow as below.

  • Create New Application
  • Write Application name and Deployment group name

  • Select deployment type
  • Add instance

  • Select deployment configuration

  • Select Service role ARN for codedeploy service by following below steps
    • Create new role.
    • On the Select role type page, with AWS Service Role selected, next to AWS CodeDeploy, choose Select.
    • On the Attach Policy page, select the box next to the AWSCodeDeployRole policy, and then choose Next Step.
    • give the service role a name
    • Choose Create role.
    • Select role ARN

    • Select role ARN into codedeploy console

  • Click on Create Application.

Step:4

  • Go to Code-Pipeline console

  • Name the pipeline and click on next step
  • Select the source as per your repository location.In this demo we have selected codecommit

  • Select repository name and branch name and click on next step
  • For build option select no build because we are not building the code right now
  • In deploy option select the deploy option from given options
  • I have used CodeDeploy for Deploy so select created Deployment group name and Application name and click on next step.
  • Create service role and attach to the pipeline
  • Review the configurations and create the pipeline.
  • You will see like below

  • The source and staging will be in progress like below

  • If codedeploy on Application server is happen successfully you will get below console

Step:5

Your index.html file is like below un version 1

Now update the code through Codecommit::

So deployment will start automatically through codepipeline as below

You will get updated deployment as below

 

 

I hope you like this blog.

Jigisha Araniya.
AWS-team,
Electromech Corporation.

Leave a Reply

Your email address will not be published. Required fields are marked *

*