Skip to content

Commit bad4351

Browse files
[PRMP-817-2] create infra for new lambda
1 parent 8393b7f commit bad4351

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

infrastructure/api.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
7575
module.send-feedback-gateway,
7676
module.send-feedback-lambda,
7777
module.review_document_version_gateway,
78+
module.review_document_status_gateway,
7879
module.update_doc_ref_lambda,
7980
module.update-upload-state-gateway,
8081
module.update-upload-state-lambda,

infrastructure/gateway-review-document.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,15 @@ module "review_document_version_gateway" {
3232
"method.request.path.version" = true
3333
}
3434
}
35+
36+
module "review_document_status_gateway" {
37+
source = "./modules/gateway"
38+
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
39+
parent_id = module.review_document_version_gateway.gateway_resource_id
40+
gateway_path = "Status"
41+
http_methods = ["GET"]
42+
require_credentials = true
43+
authorization = "CUSTOM"
44+
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
45+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
46+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)