version: 2.1
orbs:
  aws-ecr: circleci/aws-ecr@8.1.2 # use the AWS ECR orb
  aws-ecs: circleci/aws-ecs@3.2.0 # use the AWS ECS orb
  aws-cli: circleci/aws-cli@3.1.1 # use the AWS CLI orb
workflows:
  build-and-deploy:
    jobs:
      - aws-ecr/build-and-push-image: # orb built-in job
          context: AWS
          repo: '${MY_APP_PREFIX}'
          tag: '${CIRCLE_SHA1}'
      - aws-ecs/deploy-service-update: # orb built-in job
          context: AWS
          requires:
            - aws-ecr/build-and-push-image
          family: '${MY_APP_PREFIX}-service'
          cluster: '${MY_APP_PREFIX}-cluster'
          container-image-name-updates: 'container=${MY_APP_PREFIX}-service,tag=${CIRCLE_SHA1}'