Skip to content

Commit 86d60de

Browse files
authored
[PRMT-439] Update Infrastructure and workflows to handle CIS2 Mock workspaces (#333)
1 parent be44012 commit 86d60de

27 files changed

+307
-241
lines changed

.github/workflows/terraform-deploy-feature-to-sandbox-with-dispatch.yml

Lines changed: 0 additions & 115 deletions
This file was deleted.

.github/workflows/terraform-destroy-dev-environments-cron.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/terraform-destroy-environment-manual.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ jobs:
9292
with:
9393
ref: ${{ inputs.build_branch }}
9494

95+
- name: Set up Python
96+
uses: actions/setup-python@v5
97+
with:
98+
python-version: 3.11
99+
100+
- name: Install Python Dependencies
101+
run: |
102+
python3 -m venv ./venv
103+
./venv/bin/pip3 install --upgrade pip boto3
104+
95105
- name: Configure AWS Credentials
96106
uses: aws-actions/configure-aws-credentials@v4
97107
with:
@@ -118,3 +128,6 @@ jobs:
118128
- name: Terraform Destroy
119129
run: terraform destroy -auto-approve -var-file="${{ inputs.terraform_vars }}"
120130
working-directory: ./infrastructure
131+
132+
- name: Run Terraform Workspace Cleanup Script
133+
run: ./venv/bin/python3 -u scripts/cleanup_terraform_states.py ${{ inputs.sandbox_workspace }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 'Destroy Sandbox Environments (CRON)'
2+
3+
on:
4+
schedule:
5+
- cron: 59 17 * * 1-5 # utc time
6+
7+
permissions:
8+
pull-requests: write
9+
id-token: write # This is required for requesting the JWT
10+
contents: read # This is required for actions/checkout
11+
12+
jobs:
13+
destroy_process:
14+
name: Destroy Sandbox Environments
15+
runs-on: ubuntu-latest
16+
environment: development
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
ref: main
22+
23+
- name: Configure AWS Credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
27+
role-skip-session-tagging: true
28+
aws-region: ${{ vars.AWS_REGION }}
29+
mask-aws-account-id: true
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: 3.11
35+
36+
- name: Install Python Dependencies
37+
run: |
38+
python3 -m venv ./venv
39+
./venv/bin/pip3 install --upgrade pip boto3 requests
40+
41+
- name: Run Sandbox Cleanup Script
42+
run: ./venv/bin/python3 -u scripts/cleanup_sandboxes.py
43+
env:
44+
GIT_WORKFLOW_PAT: ${{ secrets.GIT_WORKFLOW_PAT }} # Has "repo" and "workflow" privileges

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ tfplan
3535

3636
.idea/
3737
.vscode/
38+
venv/

infrastructure/app_config.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ module "ndr-app-config" {
44
owner = var.owner
55
config_environment_name = terraform.workspace
66
config_profile_name = "config-profile-${terraform.workspace}"
7+
dev_config_enabled = !local.is_production
78
}

infrastructure/ecr.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
module "ndr-docker-ecr-ui" {
2-
source = "./modules/ecr/"
3-
app_name = "ndr-${terraform.workspace}-app"
2+
source = "./modules/ecr/"
3+
app_name = "ndr-${terraform.workspace}-app"
4+
allow_force_destroy = local.is_force_destroy
5+
46
environment = var.environment
57
owner = var.owner
68
}
9+
710
module "ndr-docker-ecr-data-collection" {
8-
count = local.is_sandbox ? 0 : 1
9-
source = "./modules/ecr/"
10-
app_name = "${terraform.workspace}-data-collection"
11+
count = local.is_sandbox ? 0 : 1
12+
source = "./modules/ecr/"
13+
app_name = "${terraform.workspace}-data-collection"
14+
allow_force_destroy = local.is_force_destroy
15+
1116
environment = var.environment
1217
owner = var.owner
1318
}

infrastructure/lambda-edge-presign.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module "edge_presign_alarm" {
1010
}
1111

1212
resource "aws_cloudwatch_log_metric_filter" "edge_presign_error" {
13+
count = local.is_sandbox ? 0 : 1
1314
name = "EdgePresignErrorFilter"
1415
pattern = "%LambdaError%"
1516
log_group_name = "/aws/lambda/us-east-1.${module.edge-presign-lambda.function_name}"

infrastructure/modules/app_config/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module "app_config" {
5757
|------|-------------|------|---------|:--------:|
5858
| <a name="input_config_environment_name"></a> [config\_environment\_name](#input\_config\_environment\_name) | Name of the AppConfig environment (e.g., dev, prod). | `string` | n/a | yes |
5959
| <a name="input_config_profile_name"></a> [config\_profile\_name](#input\_config\_profile\_name) | Name of the AppConfig configuration profile. | `string` | n/a | yes |
60+
| <a name="input_dev_config_enabled"></a> [dev\_config\_enabled](#input\_dev\_config\_enabled) | n/a | `bool` | n/a | yes |
6061
| <a name="input_environment"></a> [environment](#input\_environment) | Deployment environment tag used for naming and labeling (e.g., dev, prod) | `string` | n/a | yes |
6162
| <a name="input_owner"></a> [owner](#input\_owner) | Identifies the team or person responsible for the resource (used for tagging). | `string` | n/a | yes |
6263
## Outputs

infrastructure/modules/app_config/configurations/pre-prod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"enabled": "false"
2828
},
2929
"useSmartcardAuth": {
30-
"enabled": "false"
30+
"enabled": "true"
3131
},
3232
"lloydGeorgeValidationStrictModeEnabled": {
3333
"enabled": "true"

0 commit comments

Comments
 (0)