Skip to content

Commit c1932fd

Browse files
committed
Work in progress - started off tf changes
1 parent c53c49d commit c1932fd

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

terraform/ack_lambda.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,6 @@ resource "aws_iam_policy" "ack_lambda_exec_policy" {
123123
"${aws_s3_bucket.batch_data_destination_bucket.arn}/*"
124124
]
125125
},
126-
{
127-
Effect = "Allow"
128-
Action = "lambda:InvokeFunction"
129-
Resource = [
130-
aws_lambda_function.file_processor_lambda.arn,
131-
]
132-
},
133126
{
134127
Effect = "Allow"
135128
Action = [
@@ -165,6 +158,7 @@ resource "aws_cloudwatch_log_group" "ack_lambda_log_group" {
165158
name = "/aws/lambda/${local.short_prefix}-ack-lambda"
166159
retention_in_days = 30
167160
}
161+
168162
resource "aws_iam_policy" "ack_s3_kms_access_policy" {
169163
name = "${local.short_prefix}-ack-s3-kms-policy"
170164
description = "Allow Lambda to decrypt environment variables"
@@ -199,6 +193,7 @@ resource "aws_iam_role_policy_attachment" "lambda_kms_policy_attachment" {
199193
role = aws_iam_role.ack_lambda_exec_role.name
200194
policy_arn = aws_iam_policy.ack_s3_kms_access_policy.arn
201195
}
196+
202197
# Lambda Function with Security Group and VPC.
203198
resource "aws_lambda_function" "ack_processor_lambda" {
204199
function_name = "${local.short_prefix}-ack-lambda"

terraform/batch_processor_filter_lambda.tf

Whitespace-only changes.

terraform/file_name_processor.tf

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,6 @@ resource "aws_iam_policy" "filenameprocessor_lambda_exec_policy" {
161161
"firehose:PutRecordBatch"
162162
],
163163
"Resource" : "arn:aws:firehose:*:*:deliverystream/${module.splunk.firehose_stream_name}"
164-
},
165-
{
166-
Effect = "Allow"
167-
Action = "lambda:InvokeFunction"
168-
Resource = [
169-
"arn:aws:lambda:${var.aws_region}:${var.immunisation_account_id}:function:imms-${var.sub_environment}-filenameproc_lambda",
170-
]
171164
}
172165
]
173166
})
@@ -184,7 +177,7 @@ resource "aws_iam_policy" "filenameprocessor_lambda_sqs_policy" {
184177
Action = [
185178
"sqs:SendMessage"
186179
],
187-
Resource = aws_sqs_queue.supplier_fifo_queue.arn
180+
Resource = aws_sqs_queue.batch_file_created.arn
188181
}]
189182
})
190183
}
@@ -266,6 +259,7 @@ resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dynamo_acces
266259
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
267260
policy_arn = aws_iam_policy.filenameprocessor_dynamo_access_policy.arn
268261
}
262+
269263
# Lambda Function with Security Group and VPC.
270264
resource "aws_lambda_function" "file_processor_lambda" {
271265
function_name = "${local.short_prefix}-filenameproc_lambda"
@@ -284,14 +278,13 @@ resource "aws_lambda_function" "file_processor_lambda" {
284278
variables = {
285279
SOURCE_BUCKET_NAME = aws_s3_bucket.batch_data_source_bucket.bucket
286280
ACK_BUCKET_NAME = aws_s3_bucket.batch_data_destination_bucket.bucket
287-
QUEUE_URL = aws_sqs_queue.supplier_fifo_queue.url
281+
QUEUE_URL = aws_sqs_queue.batch_file_created.url
288282
CONFIG_BUCKET_NAME = local.config_bucket_name
289283
REDIS_HOST = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].address
290284
REDIS_PORT = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].port
291285
SPLUNK_FIREHOSE_NAME = module.splunk.firehose_stream_name
292286
AUDIT_TABLE_NAME = aws_dynamodb_table.audit-table.name
293287
FILE_NAME_GSI = "filename_index"
294-
FILE_NAME_PROC_LAMBDA_NAME = "imms-${var.sub_environment}-filenameproc_lambda"
295288

296289
}
297290
}
@@ -304,7 +297,6 @@ resource "aws_lambda_function" "file_processor_lambda" {
304297

305298
}
306299

307-
308300
# Permission for S3 to invoke Lambda function
309301
resource "aws_lambda_permission" "s3_invoke_permission" {
310302
statement_id = "AllowExecutionFromS3"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# FIFO SQS Queue - targeted by Filename Processor Lambda function
2+
resource "aws_sqs_queue" "batch_file_created" {
3+
name = "${local.short_prefix}-batch-file-created-queue.fifo"
4+
policy = data.aws_iam_policy_document.batch_file_created_queue_policy.json
5+
fifo_queue = true
6+
content_based_deduplication = true # Optional, helps with deduplication
7+
visibility_timeout_seconds = 900 # TODO - discuss and refine both this, max receives and DLQ
8+
}

0 commit comments

Comments
 (0)