Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo workspace depolyment #258

Merged
merged 10 commits into from
Jan 10, 2025
14 changes: 7 additions & 7 deletions .github/workflows/ecs_terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ on:
merge_group:
types:
- checks_requested
push:
branches:
- main
workflow_dispatch:
inputs:
workspace:
description: "The workspace to terraform against"
description: "Choose terraform workspace for deployment"
required: true
type: string
default: "dev"
type: choice
options:
- dev
- demo
default: dev

concurrency:
group: ${{ github.event.inputs.workspace }}-terraform
Expand All @@ -25,7 +25,7 @@ permissions:
contents: read

env:
workspace: dev
workspace: ${{ github.event.inputs.workspace }}

jobs:
terraform:
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/terraform_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ name: Ad-hoc Terraform Plan
run-name: Terraform plan ${{ inputs.workspace }} by @${{ github.actor }}

on:
pull_request:
branches:
- shanice/deploy_demo_ecs
merge_group:
types:
- checks_requested
workflow_dispatch:
inputs:
workspace:
description: "The workspace to terraform against"
description: "Choose terraform workspace for deployment"
required: true
type: string
default: "dev"
type: choice
options:
- dev
- demo
default: dev

concurrency:
group: ${{ github.event.inputs.workspace }}-terraform
Expand All @@ -19,7 +28,7 @@ permissions:
contents: read

env:
workspace: dev
workspace: ${{ github.event.inputs.workspace }}

jobs:
terraform:
Expand Down Expand Up @@ -49,7 +58,6 @@ jobs:

- name: Terraform
env:
# ACTION: ${{ env.terraform_action }}
BUCKET: ${{ secrets.TFSTATE_BUCKET }}
DYNAMODB_TABLE: ${{ secrets.TFSTATE_DYNAMODB_TABLE }}
REGION: ${{ vars.region }}
Expand All @@ -60,6 +68,7 @@ jobs:
TLS_KEY: ${{ secrets.TLS_KEY}}
shell: bash
run: |
echo "Deploying to ${{ github.event.inputs.workspace }}..."
rm -rf .terraform .terraform.lock.hcl
terraform init \
-var-file="$WORKSPACE.tfvars" \
Expand All @@ -68,6 +77,12 @@ jobs:
-backend-config "region=$REGION" \
|| (echo "terraform init failed, exiting..." && exit 1)
terraform workspace select "$WORKSPACE"
terraform apply -auto-approve -target=aws_acm_certificate.cloudflare_cert \
-var-file="$WORKSPACE.tfvars" \
-var "umls_api_key=${UMLS_API_KEY}" \
-var "ersd_api_key=${ERSD_API_KEY}" \
-var "qc_tls_key=${TLS_KEY}" \
-var "qc_tls_cert=${TLS_CERT}"
terraform plan \
-var-file="$WORKSPACE.tfvars" \
-var "umls_api_key=${UMLS_API_KEY}" \
Expand Down
3 changes: 3 additions & 0 deletions terraform/implementation/ecs/demo.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
owner = "skylight"
project = "qc"
region = "us-east-1"
8 changes: 4 additions & 4 deletions terraform/implementation/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ module "ecs" {

resource "aws_db_instance" "qc_db" {
allocated_storage = "10"
db_name = var.qc_db_name
identifier = var.db_identifier
db_name = "${var.qc_db_name}_${terraform.workspace}"
identifier = "${var.db_identifier}-${terraform.workspace}"
engine = var.db_engine_type
engine_version = var.db_engine_version
enabled_cloudwatch_logs_exports = ["postgresql", "upgrade"]
Expand All @@ -152,14 +152,14 @@ resource "aws_db_instance" "qc_db" {

# Create a DB subnet group
resource "aws_db_subnet_group" "this" {
name = "${var.db_identifier}-subnet-group"
name = "${var.db_identifier}-subnet-group-${terraform.workspace}"
subnet_ids = module.vpc.private_subnets

}

# Create a parameter group to configure Postgres RDS parameters
resource "aws_db_parameter_group" "this" {
name = "${var.db_identifier}-pg"
name = "${var.db_identifier}-pg-${terraform.workspace}"
family = var.db_family

parameter {
Expand Down
Loading