I tried CI/CD Pipeline using AWS S3  and CircleCI

I tried CI/CD Pipeline using AWS S3 and CircleCI

Clock Icon2022.09.09

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

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.

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

 

 

Give Amazon S3 Full Access

Setting up the Environment variable

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

Create an S3 Bucket

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

 

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

 

 

 

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

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

 

 

 

 

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.