DEV Community

Cover image for CI/CD Pipeline using AWS S3 and CircleCI
Olawale Adepoju for AWS Community Builders

Posted on • Updated on • Originally published at dev.classmethod.jp

CI/CD Pipeline using AWS S3 and CircleCI

Introduction

In a previous post, I wrote about continuous integration and continuous deployment pipeline using CircleCi.

Setting up IAM Credentials

Since the project will be connected to the AWS S3, we need to give access by creating IAM credentials. Proceed to your IAM dashboard and create a user IAM credentials.

Image description

Note: You must give programmatic access and keep the access key and secret key safe.

Image description
Give Amazon S3 Full Access

Image description

Setting up the Environment variable

Proceed to the CircleCi to set up the environment variable with the AWS Access key and Secret key

Image description

Create an S3 Bucket

Give a unique bucket name and specify an AWS region the same as in the CircleCi environment variable.

Image description

Connect to CircleCI

Set up projects on CircleCi via your repo.

Configure the config.yml file in the repo, then set up the project.



version: 2.1
jobs:
  build:
    machine:
      image: ubuntu-2004:202010-01
    steps:
      - checkout
      - run:
          name: Installing AWS CLI
          command: |
            sudo apt-get update
            sudo apt install python3-pip
            sudo pip3 install awsebcli --upgrade
      - run: cd ./app && npm install && npm run build
      - persist_to_workspace:
          root: .
          paths:
            - .
  test:
    machine:
      image: ubuntu-2004:202010-01
    steps:
      - attach_workspace:
          at: .
      - checkout
      - run: cd ./app && npm run test
      - persist_to_workspace:
          root: .
          paths:
            - .
  deploy:
    machine:
        image: ubuntu-2004:202010-01
    steps:
      - attach_workspace:
          at: .
      - checkout
      - run: aws s3 sync ./app/build s3://circleci-demo-cicd
workflows:
  build_test_deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test


Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

After successful deployment, the artifacts are stored in the S3 bucket.

Image description

You can preview the stages of the build, test, and deployment.

Image description

Top comments (0)