@@ -13,4 +13,56 @@ module "pdf-stitching-lambda" {
1313 rest_api_id = null
1414 api_execution_arn = null
1515 is_invoked_from_gateway = false
16+ }
17+
18+ resource "aws_lambda_event_source_mapping" "pdf-stitching-lambda" {
19+ event_source_arn = module. sqs-stitching-queue . arn
20+ function_name = module. pdf-stitching-lambda . lambda_arn
21+
22+ depends_on [
23+ module . pdf-stitching-lambda
24+ module . sqs-stitching
25+ ]
26+ }
27+
28+ module "pdf-stitching-lambda-alarms" {
29+ source = " modules/lambda_alarms
30+ lambda_function_name = module.pdf-stitching-lambda.function_name
31+ lambda_timeout = module.pdf-stitching-lambda.timeout
32+ lambda_name = " pdf- stitching- lambda"
33+ namespace = " AWS/ Lambda"
34+ alarm_actions = [module.pdf-stitching-alarm-topic.arn]
35+ ok_actions = [module.pdf-stitching-alarm-topic.arn]
36+ depends_on = [module.pdf-stitching-lambda, module.pdf-stitching-alarm-topic]
37+ }
38+
39+ module " pdf- stitching- alarm- topic" {
40+ source = " . / modules/ sns"
41+ sns_encryption_key_id = module.sns_encryption_key.id
42+ current_account_id = data.aws_caller_identity.current.account_id
43+ topic_name = " pdf- stitching- alarm- topic"
44+ topic_protocol = " lambda"
45+ topic_endpoint = module.pdf-stitching-lambda.lambda_arn
46+ delivery_policy = jsonencode({
47+ " Version" : " 2012 - 10 - 17 " ,
48+ " Statement" : [
49+ {
50+ " Effect" : " Allow" ,
51+ " Principal" : {
52+ " Service" : " cloudwatch. amazonaws . com "
53+ },
54+ " Action" : [
55+ " SNS: Publish" ,
56+ ],
57+ " Condition" : {
58+ " ArnLike" : {
59+ " aws: SourceArn" : " arn: aws: cloudwatch: eu- west- 2 : ${data.aws_caller_identity.current.account_id}: alarm: * "
60+ }
61+ }
62+ " Resource" : " * "
63+ }
64+ ]
65+ })
66+
67+ depends_on = [module.pdf-stitching-lambda, module.sns_encryption_key]
1668}
0 commit comments