-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlambda.db-password-rotation.tf
49 lines (43 loc) · 1.81 KB
/
lambda.db-password-rotation.tf
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
module "lambda_db_password_rotation" {
source = "terraform-aws-modules/lambda/aws"
version = "7.8.1"
function_name = "${local.prefix}-db-password-rotation"
description = "Redeploys services which depend on the main database when the password in secrets manager is rotated"
create_package = true
runtime = "nodejs18.x"
handler = "index.handler"
source_path = "../../src/lambda-db-password-rotation"
architectures = ["arm64"]
maximum_retry_attempts = 1
environment_variables = {
ECS_CLUSTER_ARN = module.ecs.cluster_arn
MAIN_DB_PASSWORD_SECRET_ARN = local.main_db_aurora_password_secret_arn
FEATURE_FLAGS_DB_PASSWORD_SECRET_ARN = local.feature_flags_db_aurora_password_secret_arn
CMS_ADMIN_ECS_SERVICE_NAME = module.ecs_service_cms_admin.name
PRIVATE_API_ECS_SERVICE_NAME = module.ecs_service_private_api.name
PUBLIC_API_ECS_SERVICE_NAME = module.ecs_service_public_api.name
FEEDBACK_API_ECS_SERVICE_NAME = module.ecs_service_feedback_api.name
FEATURE_FLAGS_ECS_SERVICE_NAME = module.ecs_service_feature_flags.name
}
attach_policy_statements = true
policy_statements = {
restart_ecs_services = {
actions = ["ecs:UpdateService"]
effect = "Allow"
resources = [
module.ecs_service_private_api.id,
module.ecs_service_public_api.id,
module.ecs_service_cms_admin.id,
module.ecs_service_feedback_api.id,
module.ecs_service_feature_flags.id,
]
}
}
create_current_version_allowed_triggers = false
allowed_triggers = {
allow_eventbridge_trigger = {
principal = "events.amazonaws.com"
source_arn = module.eventbridge.eventbridge_rule_arns["${local.prefix}-db-password-rotation"]
}
}
}