Skip to content

Commit a06efbe

Browse files
adamwhitingnhsmegan-bower4chrisbloe
authored
[PRMP-580] Add create before destroy to gateways (#462)
Co-authored-by: Megan <[email protected]> Co-authored-by: Kris Bloe <[email protected]>
1 parent d8500b1 commit a06efbe

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

.github/workflows/cron-tear-down-sandbox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Z-CRON: Tear down - Sandboxes'
22

33
on:
44
schedule:
5-
- cron: 59 17 * * 1-5 # utc time
5+
- cron: 59 18-21 * * 1-5 # utc time
66

77
permissions:
88
pull-requests: write

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ This repository is used to build the infrastructure the NDR. That is it's sole p
77
- [Terraform](https://developer.hashicorp.com/terraform/install)
88
- [Terraform docs](https://github.com/terraform-docs/terraform-docs)
99

10+
To install terraform-docs on WSL use the following commands (e.g. for v0.20.0):
11+
```
12+
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.20.0/terraform-docs-v0.20.0-$(uname)-amd64.tar.gz
13+
tar -xzf terraform-docs.tar.gz
14+
chmod +x terraform-docs
15+
sudo mv terraform-docs /usr/local/bin/terraform-docs
16+
rm terraform-docs.tar.gz
17+
```
18+
1019
## Installation
1120

1221
### pre-commit hook

infrastructure/api.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ resource "aws_api_gateway_stage" "ndr_api" {
9595
depends_on = [
9696
aws_cloudwatch_log_group.api_gateway_stage
9797
]
98+
99+
lifecycle {
100+
create_before_destroy = true
101+
}
98102
}
99103

100104
resource "aws_cloudwatch_log_group" "api_gateway_stage" {

infrastructure/api_mtls.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ resource "aws_api_gateway_base_path_mapping" "api_mapping_mtls" {
3333
stage_name = var.environment
3434
domain_name = aws_api_gateway_domain_name.custom_api_domain_mtls.domain_name
3535

36-
depends_on = [aws_api_gateway_deployment.ndr_api_deploy_mtls]
36+
depends_on = [
37+
aws_api_gateway_deployment.ndr_api_deploy_mtls,
38+
aws_api_gateway_rest_api.ndr_doc_store_api_mtls
39+
]
3740
}
3841

3942
resource "aws_api_gateway_deployment" "ndr_api_deploy_mtls" {
@@ -67,6 +70,12 @@ resource "aws_api_gateway_stage" "ndr_api_mtls" {
6770
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
6871
stage_name = var.environment
6972
xray_tracing_enabled = var.enable_xray_tracing
73+
74+
lifecycle {
75+
create_before_destroy = true
76+
}
77+
78+
depends_on = [aws_cloudwatch_log_group.mtls_api_gateway_stage]
7079
}
7180

7281
resource "aws_cloudwatch_log_group" "mtls_api_gateway_stage" {

scripts/cleanup_sandboxes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
import boto3, os, requests, sys
23

34
from botocore.exceptions import ClientError
@@ -62,3 +63,4 @@ def get_workspaces() -> list[str]:
6263
for workspace in workspaces:
6364
if workspace not in excluded:
6465
trigger_delete_workflow(token=gh_pat, sandbox=workspace)
66+
time.sleep(300) # Wait 5 min between executions to avoid an AWS concurrency issue.

0 commit comments

Comments
 (0)