Skip to content

Commit af6c41e

Browse files
authored
VED-26: Add batch forwarding Lambda to VPC. (#641)
* VED-26: Add forwarder Lambda to VPC. * VED-26: Add missing permissions for VPC access.
1 parent 793544d commit af6c41e

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

terraform/forwarder_lambda.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ resource "aws_iam_policy" "forwarding_lambda_exec_policy" {
185185
"sqs:SendMessage"
186186
]
187187
Resource = aws_sqs_queue.fifo_queue.arn
188+
},
189+
{
190+
Effect = "Allow",
191+
Action = [
192+
"ec2:CreateNetworkInterface",
193+
"ec2:DescribeNetworkInterfaces",
194+
"ec2:DeleteNetworkInterface"
195+
],
196+
Resource = "*"
188197
}
189198
]
190199
})
@@ -209,12 +218,19 @@ resource "aws_lambda_function" "forwarding_lambda" {
209218
size = 1024
210219
}
211220

221+
vpc_config {
222+
subnet_ids = local.private_subnet_ids
223+
security_group_ids = [data.aws_security_group.existing_securitygroup.id]
224+
}
225+
212226
environment {
213227
variables = {
214228
SOURCE_BUCKET_NAME = aws_s3_bucket.batch_data_source_bucket.bucket
215229
ACK_BUCKET_NAME = aws_s3_bucket.batch_data_destination_bucket.bucket
216230
DYNAMODB_TABLE_NAME = aws_dynamodb_table.events-dynamodb-table.name
217231
SQS_QUEUE_URL = aws_sqs_queue.fifo_queue.url
232+
REDIS_HOST = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].address
233+
REDIS_PORT = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].port
218234
}
219235
}
220236
kms_key_arn = data.aws_kms_key.existing_lambda_encryption_key.arn

terraform/variables.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ variable "aws_region" {
1515
}
1616

1717
locals {
18-
environment = terraform.workspace == "green" ? "prod" : terraform.workspace == "blue" ? "prod" : terraform.workspace
19-
env = terraform.workspace
20-
prefix = "${var.project_name}-${var.service}-${local.env}"
21-
short_prefix = "${var.project_short_name}-${local.env}"
22-
batch_prefix = "immunisation-batch-${local.env}"
23-
config_env = local.environment == "prod" ? "prod" : "dev"
18+
environment = terraform.workspace == "green" ? "prod" : terraform.workspace == "blue" ? "prod" : terraform.workspace
19+
env = terraform.workspace
20+
prefix = "${var.project_name}-${var.service}-${local.env}"
21+
short_prefix = "${var.project_short_name}-${local.env}"
22+
batch_prefix = "immunisation-batch-${local.env}"
23+
config_env = local.environment == "prod" ? "prod" : "dev"
2424

2525
root_domain = "${local.config_env}.vds.platform.nhs.uk"
2626
project_domain_name = data.aws_route53_zone.project_zone.name
2727
service_domain_name = "${local.env}.${local.project_domain_name}"
2828

29-
config_bucket_arn = aws_s3_bucket.batch_config_bucket.arn
30-
config_bucket_name = aws_s3_bucket.batch_config_bucket.bucket
29+
config_bucket_arn = aws_s3_bucket.batch_config_bucket.arn
30+
config_bucket_name = aws_s3_bucket.batch_config_bucket.bucket
3131

3232

3333
# Public subnet - The subnet has a direct route to an internet gateway. Resources in a public subnet can access the public internet.

0 commit comments

Comments
 (0)