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.
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.7aws-ecr: circleci/aws-ecr@6.8.2kubernetes: circleci/kubernetes@0.11.0snyk: snyk/snyk@0.0.10​defaults: &defaultsdocker:- image: circleci/node:9.11.2working_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?
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
​
​