DEV Community

loading...
Cover image for Creating Continuous Delivery Pipeline With AWS.

Creating Continuous Delivery Pipeline With AWS.

wariboko profile image David Wariboko ・4 min read

Set up a git repo, deploy a sample web app, and create a continuous delivery pipeline

Summary

I would like to share with you some of the easy steps to deploying your first web-app on AWS Elastic BeanStalk.
All we would need to make this happen are the following:-

GITHUB
Firstly, I would like to assume that you have a Github account already, but If the case happens to be that you don't have one, you have follow this link below to create one with the step-by-step procedure.

  • When you have your account created, Go to this this aws-elastic-beanstalk-express-js-sample and make fork of the repo into you own account.
  • Next we should clone the repo into our system by clicking the Green Code button and choose the "Clone with HTTPS" option. Cope the link from the clipboard icon.

Screen Shot 2021-03-24 at 11.14.26 PM

  • Open your terminal and run the following command in the directory you would like to clone the repo into

git clone https://github.com/YOUR-USERNAME/aws-elastic-beanstalk-express-js-sample

  • In the cloned folder, Open "app.js" with your code editor.

  • Change the print output in line 5 to whatever your wish, "Hello *****!" and save.

  • Add and Commit changes.
    git add app.js
    git commit -m "change line 5"

  • Push changes to repo.
    git push

Configure AWS Elastic Beanstalk

  1. Open the AWS Elastic BeanStalk Console
  2. Click on the orange "Create Application" button.
  3. Apply these steps below....

Screen Shot 2021-03-24 at 11.36.58 PM

  • Click on Create Application.. This process might take sometime to complete, so just wait patiently.

When the process is done, click on the link below Devopsgettingstarted-env, you should be redirected to another webpage saying everyone is okay!.

AWS CodeBuild

Now we would build our Node.js source code that we push to our repo on Github.
Go the AWS CodeBuild cones on your was account.

CodeBuild

  1. Click on the orange "Create project" button.
  2. "Project name" == "Build-DevOpsGEttingStated."
  3. Select "Github" from the radio selector on Source Provider.
  4. Connect using OAuth click on Github(version 1) from the radio selector. After, click on connect to Github and sign in to allow OAuth authorization with confirmation.
  5. Click on Repository on my GitHub account next.
  6. Search for the Beanstalk-express-js-sample* you forked and select it.
    Screen Shot 2021-03-25 at 8.39.06 AM

  7. Follow the example below to setup your working environment or choice whatever you prefer.
    Screen Shot 2021-03-25 at 8.55.48 AM

  8. Lastly, on buildspec select Insert build commands option, switch to editor and fill in the following commands in place of the previous one.

      version: 0.2
      phases:
          build:
            commands:
                - npm i --save
      artifacts:
          files:
              - '**/*'
Enter fullscreen mode Exit fullscreen mode

Click on the orange Create build project" button.

Test the CodeBuild project

  • `Click on the orange Start build button on the dashboard.
  • Confirm the newly loaded page references the correct Github repo and Start build.
  • Patiently wait for the build to be completed, at the end pf the "Build log" you should see a check mark with a "Succeeded" message confirming the build worked.

CodePipeline

Create a New Pipeline

  • In a browser window, open the AWS CodePipeline Console.
  • Click the orange "Create pipeline" button. A new screen will open up so you can set up the pipeline.
  • In the "Pipeline name" field type "Pipeline-DevOpsGettingStarted."
  • Visually confirm that "New service role" is selected.
  • Click the orange "Next" button.

Configure the source stage

  • Select "GitHub" from the "Source provider" dropdown menu.
  • Click the white "Connect to GitHub" button. A new browser tab will open asking you to give AWS CodePipeline access to your GitHub repo.
  • Click the green "Authorize aws-codesuite" button. Next, you will see a green box with the message "You have successfully configured the action with the provider."
  • From the "Repository" dropdown select the repo you created in Github.
  • Select "main" from the "branch" dropdown menu.
  • Visually confirm that "GitHub webhooks" is selected.
  • Click the orange "Next" button.

Configure the build stage

  • From the "Build provider" select "AWS CodeBuild."
  • Under "Region" confirm that the "US West (Oregon)" region is selected.
  • Select "Build-DevOpsGettingStarted" under "Project name."
  • Click the orange "Next" button.

Configure the deploy stage

  • Select "AWS ElasticBeanstalk" from the "Deploy provider" dropdown menu.
  • Under "Region" confirm that the "US West (Oregon)" region is selected.
  • Click the field under "Application name" and confirm you can see the app "DevOpsGettingStarted" created in Module 2.
  • Select "DevOpsGettingStarted-env" from the "Environment name" text box.
  • Click the orange "Next" button. You will now see a page where you can review the pipeline configuration.
  • Click the orange "Create pipeline" button.

Watch the pipeline execute

While watching the Pipeline Execution you will see a page with a green bar at the top. This page shows all the steps defined for the pipeline and, after a few minutes, each will change from blue to green.

  • Once the "Deploy" stage has switched to green and it says "Succeeded," click on "AWS Elastic Beanstalk." A new tab listing your AWS Elastic Beanstalk environments will open.
  • Click the URL on the "Devopsgettingstarted-env" row. You should see a web page with a white background and the text you included in your GitHub commit in Module 1.

Discussion (0)

pic
Editor guide