1+ module "search_document_reference_history_lambda" {
2+ source = " ./modules/lambda"
3+ name = " SearchDocumentReferenceHistory"
4+ handler = " handlers.search_document_reference_history_handler.lambda_handler"
5+ iam_role_policy_documents = [
6+ module . lloyd_george_reference_dynamodb_table . dynamodb_read_policy_document ,
7+ module . ndr-lloyd-george-store . s3_read_policy_document ,
8+ module . ndr-app-config . app_config_policy ,
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. document_reference_history_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+ WORKSPACE = terraform.workspace
20+ LLOYD_GEORGE_DYNAMODB_NAME = module.lloyd_george_reference_dynamodb_table.table_name
21+ }
22+
23+ depends_on = [
24+ aws_api_gateway_rest_api . ndr_doc_store_api ,
25+ module . document_reference_history_gateway ,
26+ ]
27+ }
28+
29+ module "search_document_reference_history_lambda_alarm" {
30+ source = " ./modules/lambda_alarms"
31+ lambda_function_name = module. search_document_reference_history_lambda . function_name
32+ lambda_timeout = module. search_document_reference_history_lambda . timeout
33+ lambda_name = " search_document_reference_history_handler"
34+ namespace = " AWS/Lambda"
35+ alarm_actions = [module . search_document_reference_history_lambda_alarm_topic . arn ]
36+ ok_actions = [module . search_document_reference_history_lambda_alarm_topic . arn ]
37+ }
38+
39+ module "search_document_reference_history_lambda_alarm_topic" {
40+ source = " ./modules/sns"
41+ sns_encryption_key_id = module. sns_encryption_key . id
42+ topic_name = " search-document-reference-history-lambda-alarm-topic"
43+ topic_protocol = " email"
44+ is_topic_endpoint_list = true
45+ topic_endpoint_list = local. is_sandbox ? [] : nonsensitive (split (" ," , data. aws_ssm_parameter . cloud_security_notification_email_list . value ))
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+ }
0 commit comments