Skip to content

Commit

Permalink
Chore: remove AWS deployment (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Jun 9, 2022
2 parents a4884f0 + 72e4236 commit 9f8e809
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 482 deletions.
84 changes: 0 additions & 84 deletions .aws/ecs-task.json

This file was deleted.

10 changes: 0 additions & 10 deletions .aws/set-env.sh

This file was deleted.

23 changes: 0 additions & 23 deletions .devcontainer/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
ports:
- "${DJANGO_LOCAL_PORT:-8000}:8000"
volumes:
- ../.aws/config:/home/calitp/app/config:ro
- ../fixtures:/home/calitp/app/fixtures:ro

dev:
Expand Down Expand Up @@ -40,25 +39,3 @@ services:
image: ghcr.io/cal-itp/eligibility-server@sha256:337d5b2beb1e458980be49a778efd4a47f8daa8decc5e8329c0d528596e2f196
ports:
- "5000"

s3pull:
image: amazon/aws-cli
entrypoint: [ "/bin/sh" ]
command: [ "-c", "aws s3 sync s3://${AWS_BUCKET} ." ]
environment:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
volumes:
- ../.aws/config:/aws

s3push:
image: amazon/aws-cli
entrypoint: [ "/bin/sh" ]
command: [ "-c", "aws s3 sync . s3://${AWS_BUCKET}" ]
environment:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
volumes:
- ../.aws/config:/aws
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.aws/
.devcontainer/
.git/
.github/
Expand Down
79 changes: 3 additions & 76 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Deploy to Amazon ECS (dev)
name: Deploy (dev)

on:
workflow_dispatch:
push:
branches:
- dev
paths:
- '.aws/**'
- '.github/workflows/deploy-*.yml'
- 'benefits/**'
- 'bin/**'
Expand All @@ -29,35 +28,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: AWS Login to Amazon ECR
id: aws-login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Define image paths
id: define-image-paths
env:
ECR_REGISTRY: ${{ steps.aws-login-ecr.outputs.registry }}
GIT_SHA: ${{ github.sha }}
AWS_CLI_TAG: ${{ secrets.AWS_CLI_TAG }}
run: |
echo "::set-output name=client::$ECR_REGISTRY/cal-itp-benefits-client:$GIT_SHA"
echo "::set-output name=config::$ECR_REGISTRY/aws-cli:$AWS_CLI_TAG"
- name: Docker Login to Amazon ECR
id: docker-login-ecr
uses: docker/login-action@v2
with:
registry: ${{ steps.aws-login-ecr.outputs.registry }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -69,17 +39,6 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v2

- name: Build, tag, and push image to Amazon ECR
id: build-client-image
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha,scope=cal-itp
cache-to: type=gha,scope=cal-itp,mode=max
context: .
push: true
tags: ${{ steps.define-image-paths.outputs.client }}

- name: Build, tag, and push image to GitHub Container Registry
uses: docker/build-push-action@v3
with:
Expand All @@ -89,37 +48,5 @@ jobs:
context: .
push: true
tags: |
ghcr.io/${{github.repository}}:dev
ghcr.io/${{github.repository}}:${{ github.sha }}
- name: Add environment-specific config to ECS task
env:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
.aws/set-env.sh .aws/ecs-task.json
- name: Fill in client image ID in ECS task
id: client-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: .aws/ecs-task.json
container-name: cal-itp-benefits-client
image: ${{ steps.define-image-paths.outputs.client }}

- name: Fill in config image ID in ECS task
id: config-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.client-task-def.outputs.task-definition }}
container-name: cal-itp-benefits-client-config
image: ${{ steps.define-image-paths.outputs.config }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.config-task-def.outputs.task-definition }}
service: cal-itp-benefits-client
cluster: cal-itp-clientCluster
wait-for-service-stability: true
ghcr.io/${{ github.repository }}:dev
ghcr.io/${{ github.repository }}:${{ github.sha }}
78 changes: 4 additions & 74 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to Amazon ECS (prod)
name: Deploy (prod)

on:
workflow_dispatch:
Expand All @@ -20,35 +20,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: AWS Login to Amazon ECR
id: aws-login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Define image paths
id: define-image-paths
env:
ECR_REGISTRY: ${{ steps.aws-login-ecr.outputs.registry }}
GIT_SHA: ${{ github.sha }}
AWS_CLI_TAG: ${{ secrets.AWS_CLI_TAG }}
run: |
echo "::set-output name=client::$ECR_REGISTRY/cal-itp-benefits-client:$GIT_SHA"
echo "::set-output name=config::$ECR_REGISTRY/aws-cli:$AWS_CLI_TAG"
- name: Docker Login to Amazon ECR
id: docker-login-ecr
uses: docker/login-action@v2
with:
registry: ${{ steps.aws-login-ecr.outputs.registry }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -60,17 +31,6 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v2

- name: Build, tag, and push image to Amazon ECR
id: build-client-image
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha,scope=cal-itp
cache-to: type=gha,scope=cal-itp,mode=max
context: .
push: true
tags: ${{ steps.define-image-paths.outputs.client }}

- name: Build, tag, and push image to GitHub Container Registry
uses: docker/build-push-action@v3
with:
Expand All @@ -79,36 +39,6 @@ jobs:
cache-to: type=gha,scope=cal-itp,mode=max
context: .
push: true
tags: ghcr.io/${{github.repository}}:prod

- name: Add environment-specific config to ECS task
env:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
.aws/set-env.sh .aws/ecs-task.json
- name: Fill in client image ID in ECS task
id: client-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: .aws/ecs-task.json
container-name: cal-itp-benefits-client
image: ${{ steps.define-image-paths.outputs.client }}

- name: Fill in config image ID in ECS task
id: config-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.client-task-def.outputs.task-definition }}
container-name: cal-itp-benefits-client-config
image: ${{ steps.define-image-paths.outputs.config }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.config-task-def.outputs.task-definition }}
service: cal-itp-benefits-client
cluster: cal-itp-clientCluster
wait-for-service-stability: true
tags: |
ghcr.io/${{ github.repository }}:prod
ghcr.io/${{ github.repository }}:${{ github.sha }}

0 comments on commit 9f8e809

Please sign in to comment.