Skip to content

Commit 0a262b0

Browse files
committed
Merge branch 'main' into feature/eja-eli-434-adding-owasp-dependency-scan
2 parents 1536aee + 50c0563 commit 0a262b0

File tree

8 files changed

+60
-11
lines changed

8 files changed

+60
-11
lines changed

infrastructure/stacks/api-layer/cloudwatch_alarms.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ resource "aws_cloudwatch_metric_alarm" "acm_expiry_alarms" {
477477
period = each.value.period
478478
treat_missing_data = each.value.treat_missing_data
479479

480+
dimensions = {
481+
CertificateArn = data.aws_acm_certificate.imported_cert.arn
482+
}
483+
480484
tags = {
481485
Environment = var.environment
482486
AlertType = "security"

infrastructure/stacks/api-layer/csoc_log_forwarding.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ data "aws_iam_policy_document" "cwl_subscription_assume_role" {
2222
variable = "aws:SourceAccount"
2323
values = [data.aws_caller_identity.current.account_id]
2424
}
25+
26+
condition {
27+
test = "StringLike"
28+
variable = "aws:SourceArn"
29+
values = ["arn:aws:logs:${var.default_aws_region}:${data.aws_caller_identity.current.account_id}:*"]
30+
}
2531
}
2632
}
2733

@@ -74,6 +80,17 @@ resource "aws_iam_role_policy_attachment" "cwl_to_csoc_destination" {
7480
policy_arn = aws_iam_policy.cwl_to_csoc_destination.arn
7581
}
7682

83+
# Wait for IAM role to propagate across AWS
84+
# This prevents "Make sure you have given CloudWatch Logs permission to assume the provided role" errors
85+
resource "time_sleep" "wait_for_iam_propagation" {
86+
depends_on = [
87+
aws_iam_role.cwl_subscription_role,
88+
aws_iam_role_policy_attachment.cwl_to_csoc_destination
89+
]
90+
91+
create_duration = "10s"
92+
}
93+
7794
# Create the subscription filter to forward logs to CSOC
7895
# This forwards all logs from the existing API Gateway log group to the CSOC destination
7996
# Note: A log group can have up to 2 subscription filters
@@ -87,6 +104,6 @@ resource "aws_cloudwatch_log_subscription_filter" "csoc_forwarding" {
87104
depends_on = [
88105
module.eligibility_signposting_api_gateway,
89106
aws_iam_role.cwl_subscription_role,
90-
aws_iam_role_policy_attachment.cwl_to_csoc_destination
107+
time_sleep.wait_for_iam_propagation
91108
]
92109
}

infrastructure/stacks/iams-developer-roles/github_actions_policies.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ resource "aws_iam_policy" "api_infrastructure" {
326326
"ec2:CreateTags",
327327
"ec2:DeleteTags",
328328
"ec2:CreateNetworkAclEntry",
329+
"ec2:DeleteNetworkAclEntry",
329330
"ec2:CreateNetworkAcl",
330331
"ec2:AssociateRouteTable",
331332
"ec2:CreateVpc",
@@ -343,6 +344,7 @@ resource "aws_iam_policy" "api_infrastructure" {
343344
"ec2:ReplaceNetworkAclAssociation",
344345
"ec2:DeleteSecurityGroup",
345346
"ec2:DeleteNetworkAcl",
347+
"ec2:UpdateSecurityGroupRuleDescriptionsEgress",
346348

347349
# ssm
348350
"ssm:GetParameter",

infrastructure/stacks/iams-developer-roles/iams_permissions_boundary.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ data "aws_iam_policy_document" "permissions_boundary" {
4646
"ec2:CreateTags",
4747
"ec2:DeleteTags",
4848
"ec2:CreateNetworkAclEntry",
49+
"ec2:DeleteNetworkAclEntry",
4950
"ec2:CreateNetworkAcl",
51+
"ec2:DeleteNetworkAcl",
5052
"ec2:AssociateRouteTable",
5153
"ec2:CreateVpc",
5254
"ec2:ModifyVpcAttribute",
@@ -62,7 +64,7 @@ data "aws_iam_policy_document" "permissions_boundary" {
6264
"ec2:CreateFlowLogs",
6365
"ec2:ReplaceNetworkAclAssociation",
6466
"ec2:DeleteSecurityGroup",
65-
"ec2:DeleteNetworkAcl",
67+
"ec2:UpdateSecurityGroupRuleDescriptionsEgress",
6668

6769
# EventBridge - alarm forwarding to Splunk
6870
"events:PutRule",

infrastructure/stacks/networking/vpc.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resource "aws_vpc" "main" {
2-
#checkov:skip=CKV2_AWS_11: "Ensure VPC flow logging is enabled in all VPCs"
32
cidr_block = local.vpc_cidr_block
43
enable_dns_support = true
54
enable_dns_hostnames = true

infrastructure/stacks/networking/vpc_endpoints.tf

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,34 @@ resource "aws_security_group_rule" "main_https_in" {
2020
}
2121

2222
resource "aws_security_group_rule" "main_https_out" {
23-
description = "Allow VPC Endpoint to access the actual AWS Service Endpoints"
23+
description = "Allow HTTPS access to Interface VPC Endpoints within VPC"
2424
type = "egress"
2525
from_port = local.default_port
2626
to_port = local.default_port
2727
protocol = "tcp"
28-
cidr_blocks = [local.any_ip_cidr]
28+
cidr_blocks = [local.vpc_cidr_block]
29+
security_group_id = aws_security_group.main.id
30+
}
31+
32+
# Allow egress to S3 via Gateway endpoint prefix list
33+
resource "aws_security_group_rule" "main_s3_prefix_out" {
34+
description = "Allow HTTPS access to S3 via Gateway endpoint"
35+
type = "egress"
36+
from_port = local.default_port
37+
to_port = local.default_port
38+
protocol = "tcp"
39+
prefix_list_ids = [aws_vpc_endpoint.gateways["s3"].prefix_list_id]
40+
security_group_id = aws_security_group.main.id
41+
}
42+
43+
# Allow egress to DynamoDB via Gateway endpoint prefix list
44+
resource "aws_security_group_rule" "main_dynamodb_prefix_out" {
45+
description = "Allow HTTPS access to DynamoDB via Gateway endpoint"
46+
type = "egress"
47+
from_port = local.default_port
48+
to_port = local.default_port
49+
protocol = "tcp"
50+
prefix_list_ids = [aws_vpc_endpoint.gateways["dynamodb"].prefix_list_id]
2951
security_group_id = aws_security_group.main.id
3052
}
3153

poetry.lock

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ docopt = "^0.6.2"
4242
jsonpath-rw = "^1.4.0"
4343
semver = "^3.0.4"
4444
gitpython = "^3.1.45"
45-
pytest = "^8.4.1"
45+
pytest = "^8.4.2"
4646
pytest-asyncio = "^1.2.0"
4747
pytest-cov = "^7.0.0"
4848
pytest-nhsd-apim = "^5.0.14"

0 commit comments

Comments
 (0)