This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Infrastructure and deployment for Service using Terraform (#25)
Terraform code for all the infrastructure to run and deploy the Service
- Loading branch information
1 parent
65c06d0
commit 0c39e9d
Showing
15 changed files
with
1,248 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
branches: main | ||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
- name: Build and push images | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.login-ecr.outputs.registry }}/wca-registration:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM ruby:3.2.2 | ||
EXPOSE 3000 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
WORKDIR /app | ||
|
||
# Add PPA needed to install nodejs. | ||
# From: https://github.com/nodesource/distributions | ||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - | ||
|
||
# Add PPA needed to install yarn. | ||
# From: https://yarnpkg.com/en/docs/install#debian-stable | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
yarn \ | ||
build-essential \ | ||
nodejs \ | ||
libssl-dev \ | ||
libyaml-dev \ | ||
tzdata | ||
|
||
|
||
RUN gem update --system && gem install bundler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.terraform/ | ||
*.tfvars | ||
.terraform.lock.hcl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Infrastructure | ||
|
||
The infrastructure for running the WCA Registration Service. | ||
|
||
## Setup | ||
|
||
First, install terraform and initialize with: | ||
|
||
``` | ||
terraform init | ||
terraform workspace select prod || terraform workspace new prod | ||
``` | ||
|
||
To apply changes run: | ||
|
||
``` | ||
terraform apply | ||
``` | ||
|
||
## Details | ||
|
||
The WCA Registration System runs on a single Docker container | ||
|
||
### App | ||
|
||
We use ECS to run the app container(s). Currently the service runs on one t3.small instance which can house up to two containers | ||
|
||
### Deployment | ||
|
||
To automate deployment we use a CodePipeline that is triggered by pushing a new app image to ECR. The pipeline: | ||
|
||
1. Sources the new ECR image arn. | ||
2. Prepares files necessary for CodeDeploy (`appspec.yaml`, `taskdef.json`) | ||
3. Triggers CodeDeploy to do Blue/Green deployment. |
Oops, something went wrong.