Skip to content

Commit 41168f8

Browse files
mfjarvisnhsdevws
authored andcommitted
VED-26: Attach endpoint Lambda functions to the VPC so they can connect to Redis.
1 parent a17b018 commit 41168f8

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

terraform/endpoints.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
locals {
44
policy_path = "${path.root}/policies"
5-
domain_name_url = "https://${local.service_domain_name}"
65
}
76

87
data "aws_iam_policy_document" "logs_policy_document" {
@@ -60,12 +59,14 @@ module "imms_event_endpoint_lambdas" {
6059
source = "./lambda"
6160
count = length(local.imms_endpoints)
6261

63-
prefix = local.prefix
64-
short_prefix = local.short_prefix
65-
function_name = local.imms_endpoints[count.index]
66-
image_uri = module.docker_image.image_uri
67-
policy_json = data.aws_iam_policy_document.imms_policy_document.json
68-
environments = local.imms_lambda_env_vars
62+
prefix = local.prefix
63+
short_prefix = local.short_prefix
64+
function_name = local.imms_endpoints[count.index]
65+
image_uri = module.docker_image.image_uri
66+
policy_json = data.aws_iam_policy_document.imms_policy_document.json
67+
environments = local.imms_lambda_env_vars
68+
vpc_subnet_ids = data.aws_subnets.default.ids
69+
vpc_security_group_ids = [data.aws_security_group.existing_securitygroup.id]
6970
}
7071

7172
locals {

terraform/lambda/lambda.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module "lambda_function_container_image" {
1313
architectures = ["x86_64"]
1414
timeout = 6
1515

16+
vpc_subnet_ids = var.vpc_subnet_ids
17+
vpc_security_group_ids = var.vpc_security_group_ids
18+
1619
# A JWT encode took 7 seconds at default memory size of 128 and 0.8 seconds at 1024.
1720
# 2048 gets it down to around 0.5 but since Lambda is charged at GB * ms then it costs more for minimal benefit.
1821
memory_size = 1024

terraform/lambda/variables.tf

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1-
variable "prefix" {}
2-
variable "short_prefix" {}
3-
variable "function_name" {}
4-
variable "image_uri" {}
1+
variable "prefix" {
2+
type = string
3+
}
4+
5+
variable "short_prefix" {
6+
type = string
7+
}
8+
9+
variable "function_name" {
10+
type = string
11+
}
12+
13+
variable "image_uri" {
14+
type = string
15+
}
16+
517
variable "environments" {
18+
type = map(string)
619
default = {}
720
}
821

9-
variable "policy_json" {}
22+
variable "policy_json" {
23+
type = string
24+
}
25+
26+
variable "vpc_security_group_ids" {
27+
type = list(string)
28+
default = null
29+
}
30+
31+
variable "vpc_subnet_ids" {
32+
type = list(string)
33+
default = null
34+
}

0 commit comments

Comments
 (0)