|
| 1 | +module "review-document-status-check-lambda" { |
| 2 | + source = "./modules/lambda" |
| 3 | + name = "ReviewDocumentStatusCheck" |
| 4 | + handler = "handlers.review_document_status_check.lambda_handler" |
| 5 | + iam_role_policy_documents = [ |
| 6 | + module.ndr-app-config.app_config_policy, |
| 7 | + aws_iam_policy.ssm_access_policy.policy, |
| 8 | + local.is_production ? "" : module.document_review_dynamodb_table[0].dynamodb_read_policy_document |
| 9 | + ] |
| 10 | + kms_deletion_window = var.kms_deletion_window |
| 11 | + rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id |
| 12 | + resource_id = module.review_document_status_gateway.gateway_resource_id |
| 13 | + http_methods = ["GET"] |
| 14 | + api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn |
| 15 | + lambda_environment_variables = { |
| 16 | + APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id |
| 17 | + APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id |
| 18 | + APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id |
| 19 | + DOCUMENT_REVIEW_DYNAMODB_NAME = local.is_production ? "" : module.document_review_dynamodb_table[0].dynamodb_read_policy_document |
| 20 | + WORKSPACE = terraform.workspace |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +module "review-document-status-check-lambda-alarm" { |
| 25 | + source = "./modules/lambda_alarms" |
| 26 | + lambda_function_name = module.review-document-status-check-lambda.function_name |
| 27 | + lambda_timeout = module.review-document-status-check-lambda.timeout |
| 28 | + lambda_name = "search_document_review_handler" |
| 29 | + namespace = "AWS/Lambda" |
| 30 | + alarm_actions = [module.review-document-status-check-alarm-topic.arn] |
| 31 | + ok_actions = [module.review-document-status-check-alarm-topic.arn] |
| 32 | +} |
| 33 | + |
| 34 | +module "review-document-status-check-alarm-topic" { |
| 35 | + source = "./modules/sns" |
| 36 | + sns_encryption_key_id = module.sns_encryption_key.id |
| 37 | + topic_name = "search-document-review-lambda-alarm-topic" |
| 38 | + topic_protocol = "lambda" |
| 39 | + topic_endpoint = module.review-document-status-check-lambda.lambda_arn |
| 40 | + delivery_policy = jsonencode({ |
| 41 | + "Version" : "2012-10-17", |
| 42 | + "Statement" : [ |
| 43 | + { |
| 44 | + "Effect" : "Allow", |
| 45 | + "Principal" : { |
| 46 | + "Service" : "cloudwatch.amazonaws.com" |
| 47 | + }, |
| 48 | + "Action" : [ |
| 49 | + "SNS:Publish", |
| 50 | + ], |
| 51 | + "Condition" : { |
| 52 | + "ArnLike" : { |
| 53 | + "aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*" |
| 54 | + } |
| 55 | + } |
| 56 | + "Resource" : "*" |
| 57 | + } |
| 58 | + ] |
| 59 | + }) |
| 60 | +} |
0 commit comments