-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1678 from ministryofjustice/MLPAB-2748-check-requ…
…ests-for-addresses-not-on-the-allow-list-are-dropped MLPAB-2748 - Check egress via network firewall
- Loading branch information
Showing
15 changed files
with
145 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
misconfigurations: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM public.ecr.aws/lambda/python:3.13 | ||
|
||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
|
||
COPY lambda/egress_checker ${LAMBDA_TASK_ROOT} | ||
|
||
RUN pip install --no-cache-dir --requirement requirements.txt | ||
|
||
CMD [ "main.lambda_handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import json | ||
import requests # type: ignore | ||
|
||
def lambda_handler(event, context): | ||
response = requests.get('https://google.com') | ||
return { | ||
'statusCode': response.status_code, | ||
'body': response.text | ||
} | ||
|
||
|
||
if __name__ == '__main__': | ||
output = lambda_handler("event", "contenxt") | ||
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests==v2.32.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module "egress_checker" { | ||
count = var.egress_checker_enabled ? 0 : 1 | ||
source = "./modules/egress_checker" | ||
lambda_function_image_ecr_url = var.egress_checker_repository_url | ||
lambda_function_image_tag = var.egress_checker_container_version | ||
event_received_lambda_role = var.iam_roles.event_received_lambda | ||
vpc_config = { | ||
subnet_ids = data.aws_subnet.application[*].id | ||
security_group_ids = [data.aws_security_group.lambda_egress.id] | ||
} | ||
|
||
providers = { | ||
aws.region = aws.region | ||
aws.management = aws.management | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
terraform/environment/region/modules/egress_checker/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
data "aws_kms_alias" "cloudwatch_application_logs_encryption" { | ||
name = "alias/${data.aws_default_tags.current.tags.application}_cloudwatch_application_logs_encryption" | ||
provider = aws.region | ||
} | ||
|
||
data "aws_default_tags" "current" { | ||
provider = aws.region | ||
} | ||
|
||
module "egress_checker" { | ||
source = "../lambda" | ||
lambda_name = "egress-checker" | ||
description = "Function to check egress from the VPC via the network firewall" | ||
image_uri = "${var.lambda_function_image_ecr_url}:${var.lambda_function_image_tag}" | ||
aws_iam_role = var.event_received_lambda_role | ||
environment = data.aws_default_tags.current.tags.environment-name | ||
kms_key = data.aws_kms_alias.cloudwatch_application_logs_encryption.target_key_arn | ||
iam_policy_documents = [] | ||
timeout = 300 | ||
memory = 1024 | ||
vpc_config = { | ||
subnet_ids = var.vpc_config.subnet_ids | ||
security_group_ids = var.vpc_config.security_group_ids | ||
} | ||
providers = { | ||
aws.region = aws.region | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
terraform/environment/region/modules/egress_checker/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
variable "lambda_function_image_ecr_url" { | ||
type = string | ||
} | ||
|
||
variable "lambda_function_image_tag" { | ||
type = string | ||
} | ||
|
||
variable "event_received_lambda_role" { | ||
type = any | ||
} | ||
|
||
variable "vpc_config" { | ||
description = "Configuration block for VPC" | ||
type = object({ | ||
subnet_ids = list(string) | ||
security_group_ids = list(string) | ||
}) | ||
} |
14 changes: 14 additions & 0 deletions
14
terraform/environment/region/modules/egress_checker/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_version = ">= 1.5.2" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.82.0" | ||
configuration_aliases = [ | ||
aws.region, | ||
aws.management | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters