Skip to content

Commit be47828

Browse files
authored
Merge branch 'main' into feature/CCM-15185-List-Letters-Queue
2 parents 8f9bb48 + 9b1e49c commit be47828

File tree

9 files changed

+63
-1
lines changed

9 files changed

+63
-1
lines changed

infrastructure/terraform/components/api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ No requirements.
1515
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"supapi"` | no |
1616
| <a name="input_core_account_id"></a> [core\_account\_id](#input\_core\_account\_id) | AWS Account ID for Core | `string` | `"000000000000"` | no |
1717
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
18+
| <a name="input_csoc_destination_account"></a> [csoc\_destination\_account](#input\_csoc\_destination\_account) | value of the CSOC destination account, if applicable. If null, CSOC destination account will not be added as a resource in the logging policy | `string` | `"000000000000"` | no |
19+
| <a name="input_csoc_log_forwarding"></a> [csoc\_log\_forwarding](#input\_csoc\_log\_forwarding) | Enable forwarding of API Gateway logs to CSOC | `bool` | `true` | no |
1820
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1921
| <a name="input_disable_gateway_execute_endpoint"></a> [disable\_gateway\_execute\_endpoint](#input\_disable\_gateway\_execute\_endpoint) | Disable the execution endpoint for the API Gateway | `bool` | `true` | no |
2022
| <a name="input_enable_alarms"></a> [enable\_alarms](#input\_enable\_alarms) | Enable CloudWatch alarms for this deployed environment | `bool` | `true` | no |

infrastructure/terraform/components/api/api_gateway_rest_api.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ resource "aws_api_gateway_rest_api" "main" {
33
body = local.openapi_spec
44
description = "Suppliers API"
55
disable_execute_api_endpoint = var.disable_gateway_execute_endpoint
6+
7+
lifecycle {
8+
replace_triggered_by = [terraform_data.rest_api_security_policy]
9+
}
610
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
locals {
2+
rest_api_security_policy = "SecurityPolicy_TLS12_PFS_2025_EDGE"
3+
rest_api_endpoint_access_mode = "STRICT"
4+
}
5+
6+
resource "terraform_data" "rest_api_security_policy" {
7+
input = {
8+
security_policy = local.rest_api_security_policy
9+
endpoint_access_mode = local.rest_api_endpoint_access_mode
10+
}
11+
}

infrastructure/terraform/components/api/cloudwatch_log_group_api_gateway_access.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ resource "aws_cloudwatch_log_subscription_filter" "api_gateway_access" {
1010
filter_pattern = ""
1111
destination_arn = local.destination_arn
1212
}
13+
14+
resource "aws_cloudwatch_log_subscription_filter" "api_gateway" {
15+
count = var.csoc_log_forwarding ? 1 : 0
16+
name = replace(aws_cloudwatch_log_group.api_gateway_access.name, "/", "-")
17+
log_group_name = aws_cloudwatch_log_group.api_gateway_access.name
18+
role_arn = data.aws_iam_role.csoc_subscription[0].arn
19+
filter_pattern = ""
20+
destination_arn = local.csoc_api_gw_log_destination_arn
21+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "aws_iam_role" "csoc_subscription" {
2+
count = var.csoc_log_forwarding ? 1 : 0
3+
name = "nhs-main-acct-api-log-subscription-role"
4+
}

infrastructure/terraform/components/api/locals.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ locals {
77
openapi_spec = templatefile("${path.module}/resources/spec.tmpl.json", {
88
APIG_EXECUTION_ROLE_ARN = aws_iam_role.api_gateway_execution_role.arn
99
AWS_REGION = var.region
10+
SECURITY_POLICY = local.rest_api_security_policy
11+
ENDPOINT_ACCESS_MODE = local.rest_api_endpoint_access_mode
1012
AUTHORIZER_LAMBDA_ARN = module.authorizer_lambda.function_arn
1113
GET_LETTER_LAMBDA_ARN = module.get_letter.function_arn
1214
GET_LETTERS_LAMBDA_ARN = module.get_letters.function_arn
@@ -40,4 +42,9 @@ locals {
4042

4143
event_cache_bucket_name = lookup(module.eventpub.s3_bucket_event_cache, "bucket", null)
4244
eventsub_event_cache_bucket_name = lookup(module.eventsub.s3_bucket_event_cache, "bucket", null)
45+
46+
csoc_api_gw_log_destination_arn = format("arn:aws:logs:%s:%s:destination:api_gateway_log_destination",
47+
var.region,
48+
var.csoc_destination_account
49+
)
4350
}

infrastructure/terraform/components/api/resources/spec.tmpl.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,7 @@
307307
}
308308
}
309309
}
310-
}
310+
},
311+
"x-amazon-apigateway-endpoint-access-mode": "${ENDPOINT_ACCESS_MODE}",
312+
"x-amazon-apigateway-security-policy": "${SECURITY_POLICY}"
311313
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,15 @@ variable "event_anomaly_band_width" {
229229
description = "The width of the anomaly detection band. Higher values (e.g. 4-6) reduce sensitivity and noise, lower values (e.g. 2-3) increase sensitivity. Recommended: 2-4."
230230
default = 4
231231
}
232+
233+
variable "csoc_log_forwarding" {
234+
type = bool
235+
description = "Enable forwarding of API Gateway logs to CSOC"
236+
default = true
237+
}
238+
239+
variable "csoc_destination_account" {
240+
type = string
241+
description = "value of the CSOC destination account, if applicable. If null, CSOC destination account will not be added as a resource in the logging policy"
242+
default = "000000000000"
243+
}

scripts/config/markdownlint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SEE: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
2+
3+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
4+
MD013: false
5+
6+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
7+
MD024:
8+
siblings_only: true
9+
10+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
11+
MD033: false

0 commit comments

Comments
 (0)