Skip to content

Commit f97e087

Browse files
[PRMP-538] Add EventBridge rule for expedite folder (#497)
1 parent 588754b commit f97e087

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

infrastructure/lambda-bulk-upload-metadata-processor.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,47 @@ module "bulk-upload-metadata-processor-alarm-topic" {
7272

7373
depends_on = [module.bulk-upload-metadata-processor-lambda, module.sns_encryption_key]
7474
}
75+
76+
resource "aws_cloudwatch_event_rule" "bulk_upload_metadata_processor_lambda_expedite" {
77+
name = "${terraform.workspace}-staging-bulk-store-expedite-folder-object-created-rule"
78+
description = "Trigger bulk_upload_metadata_processor_lambda when a file is added to the expedite/ folder in the staging-bulk-store bucket"
79+
event_pattern = jsonencode({
80+
"source" : ["aws.s3"],
81+
"detail-type" : ["Object Created"],
82+
"detail" : {
83+
"bucket" : {
84+
"name" : [module.ndr-bulk-staging-store.bucket_id]
85+
},
86+
"object" : {
87+
"key" : [{
88+
"prefix" : "expedite/"
89+
}]
90+
}
91+
}
92+
})
93+
depends_on = [
94+
module.ndr-bulk-staging-store
95+
]
96+
}
97+
98+
resource "aws_cloudwatch_event_target" "bulk_upload_metadata_processor_lambda" {
99+
rule = aws_cloudwatch_event_rule.bulk_upload_metadata_processor_lambda_expedite.name
100+
arn = module.bulk-upload-metadata-processor-lambda.lambda_arn
101+
target_id = "bulk-upload-metadata-processor-lambda"
102+
depends_on = [
103+
module.bulk-upload-metadata-processor-lambda,
104+
aws_cloudwatch_event_rule.bulk_upload_metadata_processor_lambda_expedite
105+
]
106+
}
107+
108+
resource "aws_lambda_permission" "bulk_upload_metadata_processor_lambda_expedite" {
109+
statement_id = "AllowEventBridgeInvoke"
110+
action = "lambda:InvokeFunction"
111+
function_name = module.bulk-upload-metadata-processor-lambda.function_name
112+
principal = "events.amazonaws.com"
113+
source_arn = aws_cloudwatch_event_rule.bulk_upload_metadata_processor_lambda_expedite.arn
114+
depends_on = [
115+
module.bulk-upload-metadata-processor-lambda,
116+
aws_cloudwatch_event_rule.bulk_upload_metadata_processor_lambda_expedite
117+
]
118+
}

infrastructure/modules/gateway/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module "api_gateway_resource" {
7676
| <a name="input_http_methods"></a> [http\_methods](#input\_http\_methods) | List of allowed HTTP methods for the resource (e.g., ["GET", "POST"]). | `list(string)` | n/a | yes |
7777
| <a name="input_origin"></a> [origin](#input\_origin) | Allowed origin for CORS requests (e.g., '*', or specific domain). | `string` | `"'*'"` | no |
7878
| <a name="input_parent_id"></a> [parent\_id](#input\_parent\_id) | ID of the parent API Gateway resource (e.g., root path or another nested resource). | `string` | n/a | yes |
79+
| <a name="input_request_parameters"></a> [request\_parameters](#input\_request\_parameters) | Request parameters for the API Gateway method. | `map(string)` | `{}` | no |
7980
| <a name="input_require_credentials"></a> [require\_credentials](#input\_require\_credentials) | Sets the value of 'Access-Control-Allow-Credentials' which controls whether auth cookies are needed. | `bool` | n/a | yes |
8081
## Outputs
8182

0 commit comments

Comments
 (0)