Skip to content

Commit

Permalink
chore(test-env): add new environment named test in the deployment pip…
Browse files Browse the repository at this point in the history
…eline
  • Loading branch information
jimmypalelil committed Feb 5, 2025
1 parent 35f7b0c commit b8dc917
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 15 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/fta-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ on:
# schedule: [cron: "0 3 * * *"] # Every day at 3 AM
workflow_call:
inputs:
app_env:
required: true
description: 'The APP env separates between AWS ENV and Actual APP, since AWS dev is where PR, and TEST is deployed'
type: string
environment_name:
description: 'The name of the environment to deploy to'
required: true
type: string
tag:
description: 'The tag of the containers to deploy'
required: true
Expand All @@ -17,14 +25,14 @@ permissions:
pull-requests: write

jobs:
run-fta-dev-migration:
name: Run FTA Dev Migration
run-fta-migration:
name: Run FTA ${{ inputs.app_env }} Migration
uses: ./.github/workflows/.aws-deployer.yml
with:
environment_name: dev
app_env: ${{ inputs.app_env || 'dev' }}
environment_name: ${{ inputs.environment_name || 'dev' }}
command: apply
flyway_image: ghcr.io/bcgov/nr-rec-resources/migrations/fta:${{ inputs.tag || 'latest' }}
working_directory: migration
tag: ${{ inputs.tag }}
app_env: dev
secrets: inherit
32 changes: 25 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ jobs:
secrets: inherit

# Running FTA migration after each dev deployment since we are clearing the database each run
fta-migration:
fta-migration-dev:
needs: deploy-to-aws-dev
name: FTA Migration
uses: ./.github/workflows/fta-migration.yml
with:
app_env: dev
environment_name: dev
tag: ${{ github.sha }}
secrets: inherit

Expand All @@ -70,14 +72,30 @@ jobs:
- name: Review Test Deployment
run: echo "Reviewing Test Deployment"

# Deploys to test environment in the same AWS account as dev.
# resources in test environment uses the same vpc as the dev (Dev_vpc)
deploy-to-aws-test:
name: Deploys Application to AWS test
needs: [review-test-deployment]
runs-on: ubuntu-24.04
steps:
- name: Deploy to AWS test
# Placeholder
run: echo "Deploying to AWS test"
needs: [ review-test-deployment ]
uses: ./.github/workflows/.deploy-app.yml
with:
app_env: test
command: apply
environment_name: test
tag: ${{ github.sha }}
secrets: inherit

# Running FTA migration after each dev deployment since we are clearing the database each run
fta-migration-test:
needs: deploy-to-aws-test
name: FTA Migration
uses: ./.github/workflows/fta-migration.yml
with:
app_env: test
environment_name: test
tag: ${{ github.sha }}
secrets: inherit


release:
name: Release
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/api/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ locals {
tools = "Tools"
unclass = "UnClass"
}
environment = local.env_map[lower(var.target_env)]
environment = local.env_map[lower(var.target_env) == "test" ? "dev" : lower(var.target_env)]
vpc_name = "${local.environment}_vpc"
availability_zones = ["a", "b"]
web_subnet_names = [for az in local.availability_zones : "Web_${local.environment}_az${az}_net"]
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/database/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ locals {
tools = "Tools"
unclass = "UnClass"
}
environment = local.env_map[lower(var.target_env)]
environment = local.env_map[lower(var.target_env) == "test" ? "dev" : lower(var.target_env)]
vpc_name = "${local.environment}_vpc"
availability_zones = ["a", "b"]
web_subnet_names = [for az in local.availability_zones : "Web_${local.environment}_az${az}_net"]
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/frontend/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ locals {
tools = "Tools"
unclass = "UnClass"
}
environment = local.env_map[lower(var.target_env)]
environment = local.env_map[lower(var.target_env) == "test" ? "dev" : lower(var.target_env)]
vpc_name = "${local.environment}_vpc"
availability_zones = ["a", "b"]
web_subnet_names = [for az in local.availability_zones : "Web_${local.environment}_az${az}_net"]
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/migration/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ locals {
tools = "Tools"
unclass = "UnClass"
}
environment = local.env_map[lower(var.target_env)]
environment = local.env_map[lower(var.target_env) == "test" ? "dev" : lower(var.target_env)]
vpc_name = "${local.environment}_vpc"
availability_zones = ["a", "b"]
app_subnet_names = [for az in local.availability_zones : "App_${local.environment}_az${az}_net"]
Expand Down
24 changes: 24 additions & 0 deletions terraform/api/test/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include {
path = find_in_parent_folders()
}
locals {
app_env = get_env("app_env")
flyway_image = get_env("flyway_image")
api_image = get_env("api_image")
target_env = get_env("target_env")

}

# Include the common terragrunt configuration for all modules
generate "test_tfvars" {
path = "test.auto.tfvars"
if_exists = "overwrite"
disable_signature = true
contents = <<-EOF
target_env = "test"
flyway_image="${local.flyway_image}"
api_image="${local.api_image}"
app_env="${local.app_env}"
app_name="node-api-${local.app_env}"
EOF
}
18 changes: 18 additions & 0 deletions terraform/database/test/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include {
path = find_in_parent_folders()
}
locals {
app_env = get_env("app_env")
}

# Include the common terragrunt configuration for all modules
generate "test_tfvars" {
path = "test.auto.tfvars"
if_exists = "overwrite"
disable_signature = true
contents = <<-EOF
target_env = "test"
db_cluster_name = "qsawsc-aurora-cluster-${local.app_env}"
app_env="${local.app_env}"
EOF
}
20 changes: 20 additions & 0 deletions terraform/frontend/test/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include {
path = find_in_parent_folders()
}
locals {
app_env = get_env("app_env")
target_env = get_env("target_env")

}

# Include the common terragrunt configuration for all modules
generate "test_tfvars" {
path = "test.auto.tfvars"
if_exists = "overwrite"
disable_signature = true
contents = <<-EOF
target_env = "test"
app_env="${local.app_env}"
app_name="frontend-${local.app_env}"
EOF
}
23 changes: 23 additions & 0 deletions terraform/migration/test/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include {
path = find_in_parent_folders()
}
locals {
app_env = get_env("app_env")
flyway_image = get_env("flyway_image")
api_image = get_env("api_image")
target_env = get_env("target_env")
}

# Include the common terragrunt configuration for all modules
generate "test_tfvars" {
path = "test.auto.tfvars"
if_exists = "overwrite"
disable_signature = true
contents = <<-EOF
target_env = "test"
flyway_image="${local.flyway_image}"
api_image="${local.api_image}"
app_env="${local.app_env}"
app_name="node-api-${local.app_env}"
EOF
}

0 comments on commit b8dc917

Please sign in to comment.