@@ -3,18 +3,8 @@ locals {
33 filename_lambda_dir = abspath (" ${ path . root } /../../lambdas/filenameprocessor" )
44 filename_lambda_files = fileset (local. filename_lambda_dir , " **" )
55 filename_lambda_dir_sha = sha1 (join (" " , [for f in local . filename_lambda_files : filesha1 (" ${ local . filename_lambda_dir } /${ f } " )]))
6- dps_bucket_name_for_extended_attribute = (
7- var. environment == " prod"
8- ? " nhsd-dspp-core-prod-extended-attributes-gdp"
9- : " nhsd-dspp-core-ref-extended-attributes-gdp"
10- )
11- dps_bucket_arn_for_extended_attribute = [
12- " arn:aws:s3:::${ local . dps_bucket_name_for_extended_attribute } /*"
13- ]
146}
157
16-
17-
188resource "aws_ecr_repository" "file_name_processor_lambda_repository" {
199 image_scanning_configuration {
2010 scan_on_push = true
@@ -79,7 +69,7 @@ resource "aws_ecr_repository_policy" "filenameprocessor_lambda_ECRImageRetreival
7969 ],
8070 " Condition" : {
8171 " StringLike" : {
82- " aws:sourceArn" : " arn:aws:lambda:eu-west-2:${ var . immunisation_account_id } :function:${ local . short_prefix } -filenameproc_lambda "
72+ " aws:sourceArn" : " arn:aws:lambda:eu-west-2:${ var . immunisation_account_id } :function:${ local . short_prefix } -filenameproc-lambda "
8373 }
8474 }
8575 }
@@ -116,7 +106,7 @@ resource "aws_iam_policy" "filenameprocessor_lambda_exec_policy" {
116106 " logs:CreateLogStream" ,
117107 " logs:PutLogEvents"
118108 ]
119- Resource = " arn:aws:logs:${ var . aws_region } :${ var . immunisation_account_id } :log-group:/aws/lambda/${ local . short_prefix } -filenameproc_lambda :*"
109+ Resource = " arn:aws:logs:${ var . aws_region } :${ var . immunisation_account_id } :log-group:/aws/lambda/${ local . short_prefix } -filenameproc-lambda :*"
120110 },
121111 {
122112 Effect = " Allow"
@@ -178,7 +168,7 @@ resource "aws_iam_policy" "filenameprocessor_lambda_exec_policy" {
178168 " Action" : [
179169 " s3:PutObject"
180170 ],
181- " Resource" : local.dps_bucket_arn_for_extended_attribute
171+ " Resource" : [ " arn:aws:s3::: ${ var . dspp_submission_s3_bucket_name } /* " ]
182172 }
183173 ]
184174 })
@@ -264,14 +254,14 @@ resource "aws_iam_policy" "filenameprocessor_dps_extended_attribute_kms_policy"
264254 {
265255 Effect = " Allow" ,
266256 Action = [
267- " kms:Decrypt " ,
257+ " kms:Encrypt " ,
268258 " kms:GenerateDataKey" ,
269- " kms:DescribeKey"
259+ " kms:DescribeKey" ,
270260 ],
271261 Resource = " arn:aws:kms:eu-west-2:${ var . dspp_core_account_id } :key/*" ,
272262 " Condition" = {
273263 " ForAnyValue:StringEquals" = {
274- " kms:ResourceAliases" = " alias/${ var . dspp_kms_key_alias } "
264+ " kms:ResourceAliases" = " alias/${ var . dspp_submission_kms_key_alias } "
275265 }
276266 }
277267 }
@@ -311,7 +301,7 @@ resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dynamo_acces
311301
312302# Lambda Function with Security Group and VPC.
313303resource "aws_lambda_function" "file_processor_lambda" {
314- function_name = " ${ local . short_prefix } -filenameproc_lambda "
304+ function_name = " ${ local . short_prefix } -filenameproc-lambda "
315305 role = aws_iam_role. filenameprocessor_lambda_exec_role . arn
316306 package_type = " Image"
317307 image_uri = module. file_processor_docker_image . image_uri
@@ -329,7 +319,7 @@ resource "aws_lambda_function" "file_processor_lambda" {
329319 DPS_ACCOUNT_ID = var.dspp_core_account_id
330320 SOURCE_BUCKET_NAME = aws_s3_bucket.batch_data_source_bucket.bucket
331321 ACK_BUCKET_NAME = aws_s3_bucket.batch_data_destination_bucket.bucket
332- DPS_BUCKET_NAME = local.dps_bucket_name_for_extended_attribute
322+ DPS_BUCKET_NAME = var.dspp_submission_s3_bucket_name
333323 QUEUE_URL = aws_sqs_queue.batch_file_created.url
334324 REDIS_HOST = data.aws_elasticache_cluster.existing_redis.cache_nodes[0 ].address
335325 REDIS_PORT = data.aws_elasticache_cluster.existing_redis.cache_nodes[0 ].port
@@ -371,7 +361,7 @@ resource "aws_s3_bucket_notification" "datasources_lambda_notification" {
371361}
372362
373363resource "aws_cloudwatch_log_group" "file_name_processor_log_group" {
374- name = " /aws/lambda/${ local . short_prefix } -filenameproc_lambda "
364+ name = " /aws/lambda/${ local . short_prefix } -filenameproc-lambda "
375365 retention_in_days = 30
376366}
377367
0 commit comments