config.yml

CircleCI Configuration Walk-through

CircleCI orbs are reusable package of YAML configuration that condenses repeated pieces of config into a single line of code. Learn more about why to use an orb or explore use cases here.

The basics

We have defined our version as Config Reference 2.1 as well as the orbs we intend to leverage for our job. We will be using the following orbs:

  • aws-eks for working with Amazon Elastic Container Service for Kubernetes (Amazon EKS).

  • aws-ecr to build images and push them to the Amazon Elastic Container Registry.

  • kubernetes which is a collection of tools for working with Kubernetes on CircleCI.

  • snyk to find, fix and monitor known vulnerabilities in your app dependencies and docker image.

version: 2.1
orbs:
aws-eks: circleci/aws-eks@0.2.7
aws-ecr: circleci/aws-ecr@6.8.2
kubernetes: circleci/kubernetes@0.11.0
snyk: snyk/snyk@0.0.10
defaults: &defaults
docker:
- image: circleci/node:9.11.2
working_directory: ~/repo

In the interest of efficiency, we have also defined a few defaults for our project which we will later call from our jobs.

Did you know that you can search the CircleCI registry for several certified and partner orbs to solve most use cases?

Workflows

Our example config.yml file also organizes and orchestrates our defined jobs using workflows .

workflows:
build_and_deploy:
jobs:
- test_app
- scan_app:
requires:
- test_app
- build_and_scan_image:
requires:
- scan_app
- build_and_push_image:
requires:
- build_and_scan_image
- deploy_app:
cluster-name: ${CIRCLE_PROJECT_REPONAME}
aws-region: ${AWS_REGION_ENV_VAR_NAME}
docker-image-name: "$AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME/${CIRCLE_PROJECT_REPONAME}:${CIRCLE_SHA1}"
version-info: "${CIRCLE_SHA1}"
requires:
- build_and_push_image