|
| 1 | +module "search-document-review-lambda" { |
| 2 | + source = "./modules/lambda" |
| 3 | + name = "SearchDocumentReview" |
| 4 | + handler = "" |
| 5 | + iam_role_policy_documents = [ |
| 6 | + module.ndr-app-config.app_config_policy, |
| 7 | + ] |
| 8 | + |
| 9 | + rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id |
| 10 | + api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn |
| 11 | + http_methods = ["GET"] |
| 12 | + resource_id = module.search-document-review-gateway.gateway_resource_id |
| 13 | + kms_deletion_window = var.kms_deletion_window |
| 14 | + is_gateway_integration_needed = true |
| 15 | + is_invoked_from_gateway = true |
| 16 | + lambda_environment_variables = { |
| 17 | + APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id |
| 18 | + APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id |
| 19 | + APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id |
| 20 | + DOCUMENT_REVIEW_DYNAMO_NAME = "" |
| 21 | + WORKSPACE = terraform.workspace |
| 22 | + |
| 23 | + |
| 24 | + } |
| 25 | + depends_on = [ |
| 26 | + aws_api_gateway_rest_api.ndr_doc_store_api, |
| 27 | + module.search-document-review-gateway |
| 28 | + ] |
| 29 | +} |
| 30 | + |
| 31 | +module "search-document-review-gateway" { |
| 32 | + source = "./modules/gateway" |
| 33 | + api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id |
| 34 | + parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id |
| 35 | + http_methods = ["GET"] |
| 36 | + authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id |
| 37 | + authorization = "CUSTOM" |
| 38 | + require_credentials = true |
| 39 | + origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'" |
| 40 | + gateway_path = "SearchDocumentReview" |
| 41 | +} |
| 42 | + |
| 43 | +module "search-document-review-lambda-alarm" { |
| 44 | + source = "./modules/lambda_alarms" |
| 45 | + lambda_function_name = module.search-document-review-lambda.function_name |
| 46 | + lambda_timeout = module.search-document-review-lambda.timeout |
| 47 | + lambda_name = "" |
| 48 | + namespace = "AWS/Lambda" |
| 49 | + alarm_actions = [module.search-document-review-lambda-alarm-topic.arn] |
| 50 | + ok_actions = [module.search-document-review-lambda-alarm-topic.arn] |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | +module "search-document-review-lambda-alarm-topic" { |
| 55 | + source = "./modules/sns" |
| 56 | + sns_encryption_key_id = module.sns_encryption_key.id |
| 57 | + topic_name = "search-document-review-lambda-alarm-topic" |
| 58 | + topic_protocol = "lambda" |
| 59 | + topic_endpoint = module.search-document-review-lambda.lambda_arn |
| 60 | + delivery_policy = jsonencode({ |
| 61 | + "Version" : "2012-10-17", |
| 62 | + "Statement" : [ |
| 63 | + { |
| 64 | + "Effect" : "Allow", |
| 65 | + "Principal" : { |
| 66 | + "Service" : "cloudwatch.amazonaws.com" |
| 67 | + }, |
| 68 | + "Action" : [ |
| 69 | + "SNS:Publish", |
| 70 | + ], |
| 71 | + "Condition" : { |
| 72 | + "ArnLike" : { |
| 73 | + "aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*" |
| 74 | + } |
| 75 | + } |
| 76 | + "Resource" : "*" |
| 77 | + } |
| 78 | + ] |
| 79 | + }) |
| 80 | +} |
0 commit comments