Skip to content

Commit

Permalink
create an egress checker lambda in the vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpearce-digital committed Dec 11, 2024
1 parent 6967ebd commit 2af02a8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
15 changes: 15 additions & 0 deletions terraform/environment/region/egress-checker.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module "egress_checker" {
source = "./modules/egress_checker"
lambda_function_image_ecr_url = "311462405659.dkr.ecr.eu-west-1.amazonaws.com/egress-checker"
lambda_function_image_tag = "v0.1604.0-MLPAB2748checkrequestsforaddressesnotontheallowlistaredropped.2"
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
}
}
19 changes: 19 additions & 0 deletions terraform/environment/region/modules/egress_checker/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 = [data.aws_iam_policy_document.api_access_policy.json]
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 terraform/environment/region/modules/egress_checker/variables.tf
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 terraform/environment/region/modules/egress_checker/versions.tf
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.80.0"
configuration_aliases = [
aws.region,
aws.management
]
}
}
}

0 comments on commit 2af02a8

Please sign in to comment.