Skip to content

Commit 4fcac1f

Browse files
authored
CCM-15958: Enable CSOC APIGW Log Forwarding on api component (#514)
* CCM-15958: Enable CSOC APIGW Log Forwarding on api component * CCM-15958: Add markdown yaml file
1 parent 57e7208 commit 4fcac1f

6 files changed

Lines changed: 43 additions & 0 deletions

File tree

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/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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ locals {
3737

3838
event_cache_bucket_name = lookup(module.eventpub.s3_bucket_event_cache, "bucket", null)
3939
eventsub_event_cache_bucket_name = lookup(module.eventsub.s3_bucket_event_cache, "bucket", null)
40+
41+
csoc_api_gw_log_destination_arn = format("arn:aws:logs:%s:%s:destination:api_gateway_log_destination",
42+
var.region,
43+
var.csoc_destination_account
44+
)
4045
}

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)