├── LICENSE ├── README.md ├── buildspec.yml ├── images └── web-app-ecs-architecture.svg ├── mu.yml └── test ├── cycle.sh ├── down.sh ├── endless.sh └── up.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Brent Langston 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Amazon ECS Workshop 2 | 3 | This is part of an Amazon ECS workshop at https://ecsworkshop.com 4 | -------------------------------------------------------------------------------- /buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | build: 5 | commands: 6 | - echo '...replace with real build commands...' 7 | 8 | artifacts: 9 | files: 10 | - '**/*' 11 | 12 | -------------------------------------------------------------------------------- /images/web-app-ecs-architecture.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBBackend ALBBackend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /mu.yml: -------------------------------------------------------------------------------- 1 | --- 2 | environments: 3 | - name: acceptance 4 | provider: ecs-fargate 5 | - name: production 6 | provider: ecs-fargate -------------------------------------------------------------------------------- /test/cycle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./up.sh 4 | ./down.sh 5 | -------------------------------------------------------------------------------- /test/down.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | cd ~/environment/ecsdemo-crystal 6 | mu pipeline term 7 | 8 | cd ~/environment/ecsdemo-nodejs 9 | mu pipeline term 10 | 11 | echo "================================" 12 | echo "Beginning frontend pipeline term at $(date)" 13 | cd ~/environment/ecsdemo-frontend 14 | mu pipeline term 15 | 16 | echo "================================" 17 | echo "Beginning acceptance platform term at $(date)" 18 | cd ~/environment/ecsdemo-platform 19 | mu env term acceptance 20 | echo "================================" 21 | echo "Beginning production platform term at $(date)" 22 | mu env term production 23 | 24 | echo "================================" 25 | echo "Beginning ecr repo delete at $(date)" 26 | aws ecr delete-repository --repository-nam ${MU_NAMESPACE}-ecsdemo-frontend --force || true 27 | aws ecr delete-repository --repository-nam ${MU_NAMESPACE}-ecsdemo-nodejs --force || true 28 | aws ecr delete-repository --repository-nam ${MU_NAMESPACE}-ecsdemo-crystal --force ||true 29 | 30 | echo "================================" 31 | echo "Beginning s3 bucket delete at $(date)" 32 | export REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/' 33 | ) 34 | export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) 35 | aws s3 rm --recursive s3://${MU_NAMESPACE}-codedeploy-${REGION}-${ACCOUNT_ID} 36 | aws s3 rm --recursive s3://${MU_NAMESPACE}-codepipeline-${REGION}-${ACCOUNT_ID} 37 | 38 | echo "================================" 39 | echo "Beginning cf stack delete at $(date)" 40 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-frontend-acceptance 41 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-frontend-production 42 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-nodejs-acceptance 43 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-nodejs-production 44 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-crystal-acceptance 45 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-service-ecsdemo-crystal-production 46 | 47 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-repo-ecsdemo-frontend 48 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-repo-ecsdemo-nodejs 49 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-repo-ecsdemo-crystal 50 | 51 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-bucket-codedeploy 52 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-bucket-codepipeline 53 | 54 | echo "================================" 55 | echo "Beginning sleep 300 at $(date)" 56 | sleep 300 # delay waiting for all the other CF stacks to be deleted -- replace with a count of stacks or something 57 | 58 | echo "================================" 59 | echo "Beginning iam-common stack delete at $(date)" 60 | aws cloudformation delete-stack --stack-name ${MU_NAMESPACE}-iam-common 61 | echo "================================" 62 | echo "Teardown complete at $(date)" 63 | -------------------------------------------------------------------------------- /test/endless.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=1 4 | 5 | while true; do 6 | echo "================================" 7 | echo "Beginning test ${count} build at $(date)" 8 | ./cycle.sh 9 | echo "Ending test ${count} build at $(date)" 10 | echo "================================" 11 | ((count++)) 12 | done 13 | -------------------------------------------------------------------------------- /test/up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "================================" 6 | echo "Beginning acceptance platform build at $(date)" 7 | cd ~/environment/ecsdemo-platform 8 | mu env up acceptance 9 | echo "================================" 10 | echo "Beginning production platform build at $(date)" 11 | mu env up production 12 | 13 | echo "================================" 14 | echo "Beginning frontend pipeline build at $(date)" 15 | cd ~/environment/ecsdemo-frontend 16 | mu pipeline up -t $GITHUB_TOKEN 17 | 18 | echo "================================" 19 | echo "Beginning nodejs pipeline build at $(date)" 20 | cd ~/environment/ecsdemo-nodejs 21 | mu pipeline up -t $GITHUB_TOKEN 22 | 23 | echo "================================" 24 | echo "Beginning crystal pipeline build at $(date)" 25 | cd ~/environment/ecsdemo-crystal 26 | mu pipeline up -t $GITHUB_TOKEN 27 | --------------------------------------------------------------------------------