Skip to content

Commit 06a3729

Browse files
authored
Merge branch 'main' into NDR-97
2 parents 3ab0ec1 + 9ebd171 commit 06a3729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1453
-290
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

bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.70.0 |
12+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
1313

1414
## Modules
1515

infrastructure/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.84.0 |
12+
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
1313

1414
## Modules
1515

@@ -41,7 +41,7 @@
4141
| <a name="module_bulk-upload-report-lambda"></a> [bulk-upload-report-lambda](#module\_bulk-upload-report-lambda) | ./modules/lambda | n/a |
4242
| <a name="module_bulk_upload_metadata_preprocessor_lambda"></a> [bulk\_upload\_metadata\_preprocessor\_lambda](#module\_bulk\_upload\_metadata\_preprocessor\_lambda) | ./modules/lambda | n/a |
4343
| <a name="module_bulk_upload_report_dynamodb_table"></a> [bulk\_upload\_report\_dynamodb\_table](#module\_bulk\_upload\_report\_dynamodb\_table) | ./modules/dynamo_db | n/a |
44-
| <a name="module_cloud_storage_security"></a> [cloud\_storage\_security](#module\_cloud\_storage\_security) | cloudstoragesec/cloud-storage-security/aws | 1.7.1+css8.07.002 |
44+
| <a name="module_cloud_storage_security"></a> [cloud\_storage\_security](#module\_cloud\_storage\_security) | cloudstoragesec/cloud-storage-security/aws | 1.7.4+css8.08.002 |
4545
| <a name="module_cloudfront-distribution-lg"></a> [cloudfront-distribution-lg](#module\_cloudfront-distribution-lg) | ./modules/cloudfront | n/a |
4646
| <a name="module_cloudfront_edge_dynamodb_table"></a> [cloudfront\_edge\_dynamodb\_table](#module\_cloudfront\_edge\_dynamodb\_table) | ./modules/dynamo_db | n/a |
4747
| <a name="module_cloudfront_firewall_waf_v2"></a> [cloudfront\_firewall\_waf\_v2](#module\_cloudfront\_firewall\_waf\_v2) | ./modules/firewall_waf_v2 | n/a |
@@ -130,6 +130,8 @@
130130
| <a name="module_pdf-stitching-lambda"></a> [pdf-stitching-lambda](#module\_pdf-stitching-lambda) | ./modules/lambda | n/a |
131131
| <a name="module_pdf-stitching-lambda-alarms"></a> [pdf-stitching-lambda-alarms](#module\_pdf-stitching-lambda-alarms) | ./modules/lambda_alarms | n/a |
132132
| <a name="module_post-document-references-fhir-lambda"></a> [post-document-references-fhir-lambda](#module\_post-document-references-fhir-lambda) | ./modules/lambda | n/a |
133+
| <a name="module_pdm-document-store"></a> [pdm-document-store](#module\_pdm-document-store) | ./modules/s3/ | n/a |
134+
| <a name="module_pdm_dynamodb_table"></a> [pdm\_dynamodb\_table](#module\_pdm\_dynamodb\_table) | ./modules/dynamo_db | n/a |
133135
| <a name="module_route53_fargate_ui"></a> [route53\_fargate\_ui](#module\_route53\_fargate\_ui) | ./modules/route53 | n/a |
134136
| <a name="module_search-document-references-fhir-lambda"></a> [search-document-references-fhir-lambda](#module\_search-document-references-fhir-lambda) | ./modules/lambda | n/a |
135137
| <a name="module_search-document-references-gateway"></a> [search-document-references-gateway](#module\_search-document-references-gateway) | ./modules/gateway | n/a |
@@ -177,6 +179,8 @@
177179

178180
| Name | Type |
179181
|------|------|
182+
| [aws_api_gateway_account.logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_account) | resource |
183+
| [aws_api_gateway_api_key.api_key_pdm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_api_key) | resource |
180184
| [aws_api_gateway_api_key.apim](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_api_key) | resource |
181185
| [aws_api_gateway_authorizer.repo_authoriser](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_authorizer) | resource |
182186
| [aws_api_gateway_base_path_mapping.api_mapping](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_base_path_mapping) | resource |
@@ -206,7 +210,9 @@
206210
| [aws_api_gateway_resource.sandbox_get_document_reference_path_parameter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_resource) | resource |
207211
| [aws_api_gateway_rest_api.ndr_doc_store_api](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_rest_api) | resource |
208212
| [aws_api_gateway_stage.ndr_api](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_stage) | resource |
213+
| [aws_api_gateway_usage_plan.api_key_pdm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_usage_plan) | resource |
209214
| [aws_api_gateway_usage_plan.apim](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_usage_plan) | resource |
215+
| [aws_api_gateway_usage_plan_key.api_key_pdm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_usage_plan_key) | resource |
210216
| [aws_api_gateway_usage_plan_key.apim](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_usage_plan_key) | resource |
211217
| [aws_backup_plan.cross_account_backup_schedule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) | resource |
212218
| [aws_backup_plan.s3_continuous_backup](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) | resource |
@@ -254,6 +260,7 @@
254260
| [aws_iam_policy.ses_send_email_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
255261
| [aws_iam_policy.ssm_access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
256262
| [aws_iam_policy.ssm_access_policy_authoriser](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
263+
| [aws_iam_role.api_gateway_cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
257264
| [aws_iam_role.cognito_unauthenticated](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
258265
| [aws_iam_role.create_post_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
259266
| [aws_iam_role.cross_account_backup_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
@@ -266,6 +273,7 @@
266273
| [aws_iam_role.splunk_sqs_forwarder](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
267274
| [aws_iam_role.stitch_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
268275
| [aws_iam_role_policy.splunk_access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
276+
| [aws_iam_role_policy_attachment.api_gateway_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
269277
| [aws_iam_role_policy_attachment.backup_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
270278
| [aws_iam_role_policy_attachment.cloudwatch_rum_cognito_unauth](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
271279
| [aws_iam_role_policy_attachment.create_post_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
@@ -321,6 +329,7 @@
321329
| [aws_s3_bucket_lifecycle_configuration.doc-store-lifecycle-rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
322330
| [aws_s3_bucket_lifecycle_configuration.lg-lifecycle-rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
323331
| [aws_s3_bucket_lifecycle_configuration.ndr-zip-request-store-lifecycle-rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
332+
| [aws_s3_bucket_lifecycle_configuration.pdm_document_store](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
324333
| [aws_s3_bucket_lifecycle_configuration.staging-store-lifecycle-rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
325334
| [aws_s3_bucket_logging.logs_bucket_logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |
326335
| [aws_s3_bucket_policy.access_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
@@ -392,6 +401,8 @@
392401
| <a name="input_num_private_subnets"></a> [num\_private\_subnets](#input\_num\_private\_subnets) | Sets the number of private subnets, one per availability zone | `number` | `3` | no |
393402
| <a name="input_num_public_subnets"></a> [num\_public\_subnets](#input\_num\_public\_subnets) | Sets the number of public subnets, one per availability zone | `number` | `3` | no |
394403
| <a name="input_owner"></a> [owner](#input\_owner) | n/a | `string` | n/a | yes |
404+
| <a name="input_pdm_document_bucket_name"></a> [pdm\_document\_bucket\_name](#input\_pdm\_document\_bucket\_name) | The name of the S3 bucket to store PDM documents | `string` | `"pdm-document-store"` | no |
405+
| <a name="input_pdm_dynamodb_table_name"></a> [pdm\_dynamodb\_table\_name](#input\_pdm\_dynamodb\_table\_name) | The name of the dynamodb table to be use for pdm metadata | `string` | `"PDMDocumentMetadata"` | no |
395406
| <a name="input_poll_frequency"></a> [poll\_frequency](#input\_poll\_frequency) | n/a | `any` | n/a | yes |
396407
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `"eu-west-2"` | no |
397408
| <a name="input_staging_store_bucket_name"></a> [staging\_store\_bucket\_name](#input\_staging\_store\_bucket\_name) | n/a | `string` | `"staging-bulk-store"` | no |

infrastructure/api-key-pdm.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "aws_api_gateway_usage_plan" "api_key_pdm" {
2+
name = "${terraform.workspace}_pdm-usage-plan"
3+
api_stages {
4+
api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
5+
stage = aws_api_gateway_stage.ndr_api.stage_name
6+
}
7+
}
8+
9+
resource "aws_api_gateway_api_key" "api_key_pdm" {
10+
name = "${terraform.workspace}_pdm-api-key"
11+
}
12+
13+
resource "aws_api_gateway_usage_plan_key" "api_key_pdm" {
14+
key_id = aws_api_gateway_api_key.api_key_pdm.id
15+
key_type = "API_KEY"
16+
usage_plan_id = aws_api_gateway_usage_plan.api_key_pdm.id
17+
}

infrastructure/api.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,19 @@ resource "aws_api_gateway_stage" "ndr_api" {
9595
stage_name = var.environment
9696
xray_tracing_enabled = var.enable_xray_tracing
9797

98-
depends_on = [aws_cloudwatch_log_group.api_gateway_stage]
98+
depends_on = [
99+
aws_cloudwatch_log_group.api_gateway_stage
100+
]
99101
}
100102

101103
resource "aws_cloudwatch_log_group" "api_gateway_stage" {
102104
# Name must follow this format to allow execution logging
103105
# https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html
104106
name = "API-Gateway-Execution-Logs_${aws_api_gateway_rest_api.ndr_doc_store_api.id}/${var.environment}"
105107
retention_in_days = 0
108+
depends_on = [
109+
aws_api_gateway_account.logging
110+
]
106111
}
107112

108113
resource "aws_api_gateway_method_settings" "api_gateway_stage" {

infrastructure/backup-cross-account.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ resource "aws_backup_selection" "cross_account_backup_selection" {
5858
module.document_reference_dynamodb_table.dynamodb_table_arn,
5959
module.lloyd_george_reference_dynamodb_table.dynamodb_table_arn,
6060
module.bulk_upload_report_dynamodb_table.dynamodb_table_arn,
61-
module.statistical-reports-store.bucket_arn
61+
module.statistical-reports-store.bucket_arn,
62+
module.pdm_dynamodb_table.dynamodb_table_arn,
63+
module.pdm-document-store.bucket_arn
6264
]
6365
}
6466

infrastructure/buckets.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,25 @@ resource "aws_s3_bucket_logging" "logs_bucket_logging" {
342342
target_bucket = local.access_logs_bucket_id
343343
target_prefix = "${aws_s3_bucket.logs_bucket.id}/"
344344
}
345+
346+
module "pdm-document-store" {
347+
source = "./modules/s3/"
348+
access_logs_enabled = local.is_production
349+
access_logs_bucket_id = local.access_logs_bucket_id
350+
bucket_name = var.pdm_document_bucket_name
351+
enable_bucket_versioning = true
352+
environment = var.environment
353+
owner = var.owner
354+
force_destroy = local.is_force_destroy
355+
}
356+
357+
resource "aws_s3_bucket_lifecycle_configuration" "pdm_document_store" {
358+
bucket = module.pdm-document-store.bucket_id
359+
rule {
360+
id = "default-to-intelligent-tiering"
361+
status = "Enabled"
362+
transition {
363+
storage_class = "INTELLIGENT_TIERING"
364+
}
365+
}
366+
}

0 commit comments

Comments
 (0)