Start Building for Free
CircleCI.comAcademyBlogCommunitySupport

Migrate from AWS

8 months ago2 min read
Cloud
Server v4.x
Server v3.x
On This Page

This document provides an overview of how to migrate from AWS CodeCommit to CircleCI.

Source control setup

If you are using AWS CodeCommit, you will first need to migrate your source code to GitHub, Bitbucket or GitLab. See the following for details on how to import your code:

GitHub Enterprise

Following are the steps required for using the git command line tool to import your code into GitHub Enterprise:

  1. Create an empty repository on your GitHub Enterprise instance.

  2. Create a bare clone of your external repository on your local machine, fetching all remote tags (refs/tags/*) and copying all remote branch heads (refs/heads/\*) directly to their corresponding local branch heads.

    git clone https://external-host.com/extuser/repo.git --bare
  3. Add your GitHub Enterprise repository as a remote reference in your local clone.

    cd [repo-name]
    git remote add enterprise git@[hostname]:[owner]/[repo-name].git
  4. Push all local references (refs/*) up to your remote GitHub Enterprise repository.

    git push enterprise --mirror

Once you have imported your code into GitHub, Bitbucket or GitLab, you can start creating a project in CircleCI using the Getting Started guide.

Build configuration

Next, you will need to migrate your build configuration. On AWS CodeBuild, the build configuration is either defined in the web interface or in a file called buildspec.yml in the root directory of your source code repository. If you use shell scripts to perform your build, you can reuse those scripts in CircleCI.

First, create a CircleCI build configuration file. In the root directory of your source code repository, create a folder named .circleci and create a file in that folder named config.yml. Next, follow the CircleCI documentation here to learn how to configure the config.yml file.

The AWS CodeBuild and CircleCI configurations will be different. It may be helpful to have both AWS DevOps and CircleCI reference documentation open side-by-side to help with the conversion of the build steps:

Configuration comparison

AWSCircleCI

Define a job that executes a single build step.

phases:
  build:
    commands:
       - ./execute-script-for-job1.sh
jobs:
  job1:
    steps:
      - checkout
      - run: "execute-script-for-job1"

Specify a docker image to use for a job.

phases:
  install:
    runtime-versions:
      nodejs: 10
jobs:
  job1:
    docker:
      - image: node:10

Define a multi-stage build pipeline. Job1 and Job2 run concurrently. Once they are done, Job3 runs. Once Job3 is done, Job4 runs. An AWS CodeBuild project runs all commands sequentially. If you are running concurrent commands, you are probably using CodePipeline and multiple CodeBuild projects.

# CodePipeline Project 1
phases:
  build:
    commands:
      - make build dependencies

# CodePipeline Project 2
phases:
  build:
    commands:
      - make build artifacts

# CodePipeline Project 3
phases:
  build:
    commands:
      - make test

# CodePipeline Project 4
phases:
  build:
    commands:
      - make deploy
version: 2.1
jobs:
  job1:
    steps:
      - checkout
      - run: make build dependencies
  job2:
    steps:
      - run: make build artifacts
  job3:
    steps:
      - run: make test
  job4:
    steps:
      - run: make deploy

workflows:
  jobs:
    - job1
    - job2
    - job3:
        requires:
          - job1
          - job2
    - job4:
        requires:
          - job3

Execute jobs on multiple platforms. An AWS CodePipeline project can target a single platform only. If you are targeting multiple platforms, you’re probably using CodePipeline and multiple CodeBuild projects. CircleCI provides executors for docker, Linux and MacOS that can be combined in a single build definition.

# Environments are selected in the CodeBuild
# web console or defined in a project
# configuration file:
{
  "name": "linux project",
  "environment": {
    "type": "LINUX_CONTAINER"
  }
}

{
  "name": "windows project",
  "environment": {
    "type": "WINDOWS_CONTAINER"
  }
}
jobs:
  ubuntuJob:
    machine:
      # The image uses the current tag, which always points to the most recent
      # supported release. If stability and determinism are crucial for your CI
      # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02
      ubuntu-2004:current
    steps:
      - checkout
      - run: echo "Hello, $USER!"
  osxJob:
    macos:
      xcode: 14.2.0
    steps:
      - checkout
      - run: echo "Hello, $USER!"

Cache dependencies.

# If custom cache is enabled in the web
# console, CLI or CloudFormation, cache
# locations can be specified in the
# buildspec.yml file:

phases:
  build:
    commands:
npm install
cache:
  paths:
    - 'node_modules/**/*'
jobs:
  job1:
    steps:
      - restore_cache:
          key: source-v1-< .Revision >

      - checkout

      - run: npm install

      - save_cache:
          key: source-v1-< .Revision >
          paths:
            - "node_modules"

For larger and more complex build files, we recommend moving over the build steps in phases until you get comfortable with the CircleCI platform. We recommend this order:

  1. Execution of shell scripts and Docker compose files

  2. Workflows

  3. Artifacts

  4. Caching

  5. Triggers

  6. Performance options


Suggest an edit to this page

Make a contribution
Learn how to contribute