Skip to content

Commit 6aed812

Browse files
Merge remote-tracking branch 'origin/main' into PRMT-462
# Conflicts: # infrastructure/modules/lambda/README.md
2 parents 29cd43f + 73608d7 commit 6aed812

38 files changed

+1353
-299
lines changed

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

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# .github/workflows/terraform-dev
2-
name: 'Deploy Feature Branch to Sandbox'
2+
name: "Deploy Feature Branch to Sandbox"
33

44
on:
55
workflow_dispatch:
66
inputs:
77
buildBranch:
8-
description: 'Feature branch to push to sandbox.'
8+
description: "Feature branch to push to sandbox."
99
required: true
10-
type: 'string'
10+
type: "string"
1111
sandboxWorkspace:
12-
description: 'Which Sandbox to push to.'
12+
description: "Which Sandbox to push to."
1313
required: true
14-
type: 'string'
14+
type: "string"
1515
environment:
16-
default: 'development'
17-
description: 'Which environment should this run against'
16+
default: "development"
17+
description: "Which environment should this run against"
1818
required: true
19-
type: 'string'
19+
type: "string"
2020

2121
permissions:
2222
pull-requests: write
@@ -29,11 +29,10 @@ jobs:
2929
environment: ${{ github.event.inputs.environment }}
3030

3131
steps:
32-
# Checkout the repository to the GitHub Actions runner
33-
- name: Checkout
32+
- name: Checkout Base
3433
uses: actions/checkout@v4
3534
with:
36-
ref: ${{ github.event.inputs.buildBranch}}
35+
ref: main
3736

3837
- name: Configure AWS Credentials
3938
uses: aws-actions/configure-aws-credentials@v4
@@ -53,23 +52,51 @@ jobs:
5352
terraform_version: 1.11.4
5453
terraform_wrapper: false
5554

56-
- name: Terraform Init
57-
id: init
55+
- name: Terraform Init Base
56+
id: base_init
5857
run: terraform init -backend-config=backend.conf
5958
working-directory: ./infrastructure
6059
shell: bash
6160

62-
- name: Terraform Set Workspace
63-
id: workspace
61+
- name: Terraform Set Workspace Base
62+
id: base_workspace
6463
run: terraform workspace select -or-create ${{ github.event.inputs.sandboxWorkspace}}
6564
working-directory: ./infrastructure
6665
shell: bash
6766

68-
# Checks that all Terraform configuration files adhere to a canonical format
67+
- name: Terraform Plan Base
68+
id: base_plan
69+
run: |
70+
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf-base.plan
71+
working-directory: ./infrastructure
72+
shell: bash
73+
74+
- name: Terraform Apply Base
75+
run: terraform apply -auto-approve -input=false tf-base.plan
76+
working-directory: ./infrastructure
77+
78+
- name: Checkout Branch
79+
uses: actions/checkout@v4
80+
with:
81+
ref: ${{ github.event.inputs.buildBranch}}
82+
83+
# Checks that all Terraform configuration files adhere to a canonical format.
6984
- name: Terraform Format
7085
run: terraform fmt -check
7186
working-directory: ./infrastructure
7287

88+
- name: Terraform Init
89+
id: init
90+
run: terraform init -backend-config=backend.conf
91+
working-directory: ./infrastructure
92+
shell: bash
93+
94+
- name: Terraform Set Workspace
95+
id: workspace
96+
run: terraform workspace select ${{ github.event.inputs.sandboxWorkspace}}
97+
working-directory: ./infrastructure
98+
shell: bash
99+
73100
- name: Terraform Plan
74101
id: plan
75102
run: |

.husky/pre-commit

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

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: terraform-docs
5+
name: terraform-docs
6+
entry: python scripts/run_terraform_docs.py
7+
language: python
8+
pass_filenames: false

.terraform-docs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
formatter: "markdown table"
2+
version: "0.20"
3+
4+
header-from: main.tf
5+
footer-from: ""
6+
7+
recursive:
8+
enabled: false
9+
path: ""
10+
11+
sections:
12+
hide: []
13+
show: []
14+
15+
content: |-
16+
{{ .Requirements }}
17+
{{ .Resources }}
18+
{{ .Inputs }}
19+
{{ .Outputs }}
20+
21+
output:
22+
file: README.md
23+
mode: inject
24+
template: |-
25+
<!-- BEGIN_TF_DOCS -->
26+
{{ .Content }}
27+
<!-- END_TF_DOCS -->
28+
29+
output-values:
30+
enabled: false
31+
from: ""
32+
33+
sort:
34+
enabled: true
35+
by: name
36+
37+
settings:
38+
anchor: true
39+
color: true
40+
default: true
41+
description: true
42+
escape: true
43+
hide-empty: false
44+
html: true
45+
indent: 2
46+
lockfile: true
47+
read-comments: true
48+
required: true
49+
sensitive: true
50+
type: true

infrastructure/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| <a name="module_access-audit-gateway"></a> [access-audit-gateway](#module\_access-audit-gateway) | ./modules/gateway | n/a |
2121
| <a name="module_access-audit-lambda"></a> [access-audit-lambda](#module\_access-audit-lambda) | ./modules/lambda | n/a |
2222
| <a name="module_access_audit_dynamodb_table"></a> [access\_audit\_dynamodb\_table](#module\_access\_audit\_dynamodb\_table) | ./modules/dynamo_db | n/a |
23+
| <a name="module_alarm_state_history_table"></a> [alarm\_state\_history\_table](#module\_alarm\_state\_history\_table) | ./modules/dynamo_db | n/a |
2324
| <a name="module_api_endpoint_url_ssm_parameter"></a> [api\_endpoint\_url\_ssm\_parameter](#module\_api\_endpoint\_url\_ssm\_parameter) | ./modules/ssm_parameter | n/a |
2425
| <a name="module_auth_session_dynamodb_table"></a> [auth\_session\_dynamodb\_table](#module\_auth\_session\_dynamodb\_table) | ./modules/dynamo_db | n/a |
2526
| <a name="module_auth_state_dynamodb_table"></a> [auth\_state\_dynamodb\_table](#module\_auth\_state\_dynamodb\_table) | ./modules/dynamo_db | n/a |
@@ -87,6 +88,7 @@
8788
| <a name="module_get-report-by-ods-alarm-topic"></a> [get-report-by-ods-alarm-topic](#module\_get-report-by-ods-alarm-topic) | ./modules/sns | n/a |
8889
| <a name="module_get-report-by-ods-gateway"></a> [get-report-by-ods-gateway](#module\_get-report-by-ods-gateway) | ./modules/gateway | n/a |
8990
| <a name="module_get-report-by-ods-lambda"></a> [get-report-by-ods-lambda](#module\_get-report-by-ods-lambda) | ./modules/lambda | n/a |
91+
| <a name="module_im-alerting-lambda"></a> [im-alerting-lambda](#module\_im-alerting-lambda) | ./modules/lambda | n/a |
9092
| <a name="module_lambda-layer-core"></a> [lambda-layer-core](#module\_lambda-layer-core) | ./modules/lambda_layers | n/a |
9193
| <a name="module_lambda-layer-data"></a> [lambda-layer-data](#module\_lambda-layer-data) | ./modules/lambda_layers | n/a |
9294
| <a name="module_lloyd-george-stitch-gateway"></a> [lloyd-george-stitch-gateway](#module\_lloyd-george-stitch-gateway) | ./modules/gateway | n/a |
@@ -247,6 +249,8 @@
247249
| [aws_cognito_identity_pool_roles_attachment.cloudwatch_rum](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_identity_pool_roles_attachment) | resource |
248250
| [aws_default_security_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group) | resource |
249251
| [aws_default_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_vpc) | resource |
252+
| [aws_iam_policy.alerting_lambda_alarms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
253+
| [aws_iam_policy.alerting_lambda_tags](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
250254
| [aws_iam_policy.cloudwatch_log_query_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
251255
| [aws_iam_policy.cloudwatch_rum_cognito_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
252256
| [aws_iam_policy.copy_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
@@ -372,16 +376,21 @@
372376
| [aws_ssm_parameter.cloud_security_admin_email](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
373377
| [aws_ssm_parameter.cloud_security_notification_email_list](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
374378
| [aws_ssm_parameter.end_user_ods_code](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
379+
| [aws_ssm_parameter.im_alerting_confluence_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
375380
| [aws_ssm_parameter.mns_lambda_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
381+
| [aws_ssm_parameter.slack_alerting_bot_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
382+
| [aws_ssm_parameter.slack_alerting_channel_id](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
376383
| [aws_ssm_parameter.splunk_trusted_principal](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
377384
| [aws_ssm_parameter.target_backup_vault_arn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
385+
| [aws_ssm_parameter.teams_alerting_webhook_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
378386
| [aws_ssm_parameter.virus_scanning_subnet_cidr_range](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
379387

380388
## Inputs
381389

382390
| Name | Description | Type | Default | Required |
383391
|------|-------------|------|---------|:--------:|
384392
| <a name="input_access_audit_dynamodb_table_name"></a> [access\_audit\_dynamodb\_table\_name](#input\_access\_audit\_dynamodb\_table\_name) | The name of the dynamodb table to store the audit of access to deceased patient records | `string` | `"AccessAudit"` | no |
393+
| <a name="input_alarm_state_history_table_name"></a> [alarm\_state\_history\_table\_name](#input\_alarm\_state\_history\_table\_name) | The name of the dynamodb table to store the history of recent alarms that have been triggered. | `string` | `"AlarmStateHistory"` | no |
385394
| <a name="input_apim_environment"></a> [apim\_environment](#input\_apim\_environment) | n/a | `any` | n/a | yes |
386395
| <a name="input_auth_session_dynamodb_table_name"></a> [auth\_session\_dynamodb\_table\_name](#input\_auth\_session\_dynamodb\_table\_name) | The name of the dynamodb table to store user login sessions | `string` | `"AuthSessionReferenceMetadata"` | no |
387396
| <a name="input_auth_state_dynamodb_table_name"></a> [auth\_state\_dynamodb\_table\_name](#input\_auth\_state\_dynamodb\_table\_name) | The name of the dynamodb table to store the state values (for CIS2 authorisation) | `string` | `"AuthStateReferenceMetadata"` | no |

infrastructure/dynamo_db.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,30 @@ module "pdm_dynamodb_table" {
483483
environment = var.environment
484484
owner = var.owner
485485
}
486+
487+
488+
module "alarm_state_history_table" {
489+
source = "./modules/dynamo_db"
490+
table_name = var.alarm_state_history_table_name
491+
hash_key = "AlarmNameMetric"
492+
sort_key = "TimeCreated"
493+
deletion_protection_enabled = local.is_production
494+
point_in_time_recovery_enabled = false
495+
stream_enabled = false
496+
ttl_enabled = true
497+
ttl_attribute_name = "TimeToExist"
498+
499+
attributes = [
500+
{
501+
name = "AlarmNameMetric",
502+
type = "S"
503+
},
504+
{
505+
name = "TimeCreated"
506+
type = "N"
507+
}
508+
]
509+
510+
environment = var.environment
511+
owner = var.owner
512+
}

infrastructure/firewall.tf

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ module "firewall_waf_v2" {
66
count = local.is_sandbox ? 0 : 1
77
}
88

9+
module "firewall_waf_v2_api" {
10+
source = "./modules/firewall_waf_v2"
11+
cloudfront_acl = false
12+
environment = var.environment
13+
owner = var.owner
14+
count = local.is_sandbox ? 0 : 1
15+
api = true
16+
}
17+
918
resource "aws_wafv2_web_acl_association" "web_acl_association" {
1019
resource_arn = module.ndr-ecs-fargate-app.load_balancer_arn
1120
web_acl_arn = module.firewall_waf_v2[0].arn
@@ -18,10 +27,10 @@ resource "aws_wafv2_web_acl_association" "web_acl_association" {
1827

1928
resource "aws_wafv2_web_acl_association" "api_gateway" {
2029
resource_arn = aws_api_gateway_stage.ndr_api.arn
21-
web_acl_arn = module.firewall_waf_v2[0].arn
30+
web_acl_arn = module.firewall_waf_v2_api[0].arn
2231
count = local.is_sandbox ? 0 : 1
2332
depends_on = [
2433
aws_api_gateway_stage.ndr_api,
25-
module.firewall_waf_v2[0]
34+
module.firewall_waf_v2_api[0]
2635
]
2736
}

0 commit comments

Comments
 (0)