# yaml-language-server: $schema=../references/diagram.schema.json
title: Container delivery pipeline on AWS
subtitle: AWS CodePipeline builds each push from GitHub, deploys it to staging, waits for approval and releases it to production on Amazon Elastic Container Service
direction: down

legend:
  solid: Release path
  dashed: Monitoring

groups:
  cloud: { type: aws:cloud }
  region: { type: aws:region, label: us-east-1, in: cloud }
  pipeline: { type: aws:generic, label: AWS CodePipeline, in: region }

nodes:
  dev: { icon: aws:user, label: Developer, note: git push }
  # GitHub sits outside AWS; the pipeline reads it through an AWS CodeConnections connection.
  github: { icon: aws:git-repository, label: GitHub, note: AWS CodeConnections }
  build: { icon: aws:codebuild, label: AWS CodeBuild, note: Build and test, in: pipeline }
  deploy-stg: { icon: aws:codedeploy, label: AWS CodeDeploy, note: Deploy to staging, in: pipeline }
  approval: { icon: aws:sns, label: Amazon Simple Notification Service, note: Approval gate, in: pipeline }
  deploy-prd: { icon: aws:codedeploy, label: AWS CodeDeploy, note: Deploy to production, in: pipeline }
  ecr: { icon: aws:ecr, label: Amazon Elastic Container Registry, note: Image registry, in: region }
  ecs-stg: { icon: aws:ecs, label: Amazon ECS, note: Staging service on AWS Fargate, in: region }
  ecs-prd: { icon: aws:ecs, label: Amazon ECS, note: Production service on AWS Fargate, in: region }
  cw: { icon: aws:cloudwatch, label: Amazon CloudWatch, note: Logs and alarms, in: region }

edges:
  # constraint: false keeps the developer beside the repository and the four stages in one row.
  - { from: dev, to: github, constraint: false }
  - github -> pipeline: { label: source }
  - { from: build, to: deploy-stg, constraint: false }
  - { from: deploy-stg, to: approval, constraint: false }
  - { from: approval, to: deploy-prd, constraint: false }
  # Each stage hangs its target directly below it.
  - build -> ecr: { label: push image }
  - deploy-stg -> ecs-stg: { label: deploy }
  - deploy-prd -> ecs-prd: { label: deploy }
  # CodeDeploy watches the CloudWatch alarms and rolls back a failing release.
  - deploy-prd --> cw: alarms
  - ecs-prd --> cw: metrics
