-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda-back-channel-logout.tf
More file actions
85 lines (80 loc) · 3.53 KB
/
lambda-back-channel-logout.tf
File metadata and controls
85 lines (80 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module "back-channel-logout-gateway" {
source = "./modules/gateway"
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
parent_id = aws_api_gateway_resource.auth_resource.id
http_methods = ["POST"]
authorization = "NONE"
gateway_path = "BackChannelLogout"
require_credentials = false
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
}
module "back_channel_logout_lambda" {
source = "./modules/lambda"
name = "BackChannelLogoutHandler"
handler = "handlers.back_channel_logout_handler.lambda_handler"
iam_role_policy_documents = [
aws_iam_policy.ssm_access_policy.policy,
module.auth_session_dynamodb_table.dynamodb_read_policy_document,
module.auth_session_dynamodb_table.dynamodb_write_policy_document,
module.ndr-app-config.app_config_policy
]
kms_deletion_window = var.kms_deletion_window
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
resource_id = module.back-channel-logout-gateway.gateway_resource_id
http_methods = ["POST"]
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
lambda_environment_variables = {
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
WORKSPACE = terraform.workspace
ENVIRONMENT = var.environment
AUTH_DYNAMODB_NAME = "${terraform.workspace}_${var.auth_session_dynamodb_table_name}"
SSM_PARAM_JWT_TOKEN_PUBLIC_KEY = "jwt_token_public_key"
OIDC_CALLBACK_URL = contains(["prod"], terraform.workspace) ? "https://${var.domain}/auth-callback" : "https://${terraform.workspace}.${var.domain}/auth-callback"
}
depends_on = [
aws_api_gateway_rest_api.ndr_doc_store_api,
aws_iam_policy.ssm_access_policy,
module.auth_session_dynamodb_table,
module.back-channel-logout-gateway,
module.ndr-app-config
]
}
module "back_channel_logout_alarm" {
source = "./modules/lambda_alarms"
lambda_function_name = module.back_channel_logout_lambda.function_name
lambda_timeout = module.back_channel_logout_lambda.timeout
namespace = "AWS/Lambda"
alarm_actions = [module.back_channel_logout_alarm_topic.arn]
ok_actions = [module.back_channel_logout_alarm_topic.arn]
depends_on = [module.back_channel_logout_lambda, module.back_channel_logout_alarm_topic]
}
module "back_channel_logout_alarm_topic" {
source = "./modules/sns"
sns_encryption_key_id = module.sns_encryption_key.id
topic_name = "back-channel-logout-alarms-topic"
topic_protocol = "lambda"
topic_endpoint = module.back_channel_logout_lambda.lambda_arn
delivery_policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Principal" : {
"Service" : "cloudwatch.amazonaws.com"
},
"Action" : [
"SNS:Publish",
],
"Condition" : {
"ArnLike" : {
"aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*"
}
}
"Resource" : "*"
}
]
})
depends_on = [module.back_channel_logout_lambda, module.sns_encryption_key]
}