Skip to content

Commit fe7bf81

Browse files
chore: Add Notify api key environment variable for SSO portal (#1221)
Co-authored-by: Bryan Robitaille <bryan.robitaille.work@gmail.com>
1 parent eb1ce1a commit fe7bf81

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

aws/idp/ecs_idp.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ data "aws_iam_policy_document" "ecs_task_ssm_parameters" {
115115
aws_ssm_parameter.zitadel_admin_password.arn,
116116
aws_ssm_parameter.zitadel_database_host.arn,
117117
aws_ssm_parameter.zitadel_database_name.arn,
118-
aws_ssm_parameter.zitadel_secret_key.arn
118+
aws_ssm_parameter.zitadel_secret_key.arn,
119119
]
120120
}
121121
}

aws/idp/ecs_login.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ locals {
3030
{
3131
"name" = "CUSTOM_REQUEST_HEADERS"
3232
"value" = "Host:${local.idp_domains[0]}"
33+
},
34+
{
35+
"name" = "TEMPLATE_ID",
36+
"value" = var.gc_template_id
3337
}]
3438
secrets = [{
3539
"name" = "ZITADEL_SERVICE_USER_TOKEN"
3640
"valueFrom" = aws_ssm_parameter.idp_login_service_user_token.arn
37-
}],
41+
},
42+
{
43+
"name" = "NOTIFY_API_KEY",
44+
"valueFrom" = var.notify_api_key_secret_arn
45+
}
46+
],
3847

3948

4049
}]

aws/idp/ecs_login_iam.tf

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,27 @@ data "aws_iam_policy_document" "ecs_xray" {
7575
}
7676
}
7777

78-
resource "aws_iam_role_policy_attachment" "ecs_task_execution_forms" {
78+
resource "aws_iam_policy" "user_portal_secrets_manager" {
79+
name = "userPortalSecretsManagerKeyRetrieval"
80+
path = "/"
81+
policy = data.aws_iam_policy_document.user_portal_secrets_manager.json
82+
}
83+
84+
data "aws_iam_policy_document" "user_portal_secrets_manager" {
85+
statement {
86+
effect = "Allow"
87+
88+
actions = [
89+
"secretsmanager:GetSecretValue",
90+
]
91+
92+
resources = [
93+
var.notify_api_key_secret_arn,
94+
]
95+
}
96+
}
97+
98+
resource "aws_iam_role_policy_attachment" "ecs_task_execution_user_portal" {
7999
role = aws_iam_role.idp_user_portal.name
80100
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
81101
}
@@ -89,3 +109,8 @@ resource "aws_iam_role_policy_attachment" "ecs_xray" {
89109
role = aws_iam_role.idp_user_portal.name
90110
policy_arn = aws_iam_policy.ecs_xray.arn
91111
}
112+
113+
resource "aws_iam_role_policy_attachment" "ecs_secrets" {
114+
role = aws_iam_role.idp_user_portal.name
115+
policy_arn = aws_iam_policy.user_portal_secrets_manager.arn
116+
}

aws/idp/inputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@ variable "code_build_security_group_id" {
140140
description = "Code Build Security Group"
141141
type = string
142142
}
143+
144+
variable "notify_api_key_secret_arn" {
145+
description = "The Notify API key secret used by the ECS task and Lambda arn"
146+
type = string
147+
sensitive = true
148+
}
149+
150+
variable "gc_template_id" {
151+
description = "GC Notify send a notification templateID"
152+
type = string
153+
}

env/cloud/idp/terragrunt.hcl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
}
44

55
dependencies {
6-
paths = ["../hosted_zone", "../network", "../ecr", "../load_balancer", "../kms"]
6+
paths = ["../hosted_zone", "../network", "../ecr", "../load_balancer", "../kms", "../secrets"]
77
}
88

99
locals {
@@ -69,6 +69,15 @@ dependency "kms" {
6969
}
7070
}
7171

72+
dependency "secrets" {
73+
config_path = "../secrets"
74+
mock_outputs_allowed_terraform_commands = ["init", "fmt", "validate", "plan", "show"]
75+
mock_outputs_merge_strategy_with_state = "shallow"
76+
mock_outputs = {
77+
notify_api_key_secret_arn = "arn:aws:secretsmanager:ca-central-1:${local.aws_account_id}:secret:notify_api_key"
78+
}
79+
}
80+
7281

7382
inputs = {
7483
hosted_zone_ids = dependency.hosted_zone.outputs.hosted_zone_ids
@@ -93,13 +102,16 @@ inputs = {
93102

94103
kms_key_cloudwatch_arn = dependency.kms.outputs.kms_key_cloudwatch_arn
95104

105+
notify_api_key_secret_arn = dependency.secrets.outputs.notify_api_key_secret_arn
106+
96107
# 1 ACU ~= 2GB of memory and 1vCPU
97108
idp_database_min_acu = 1
98109
idp_database_max_acu = 4
99110

100111
# Overwritten in GitHub Actions by TFVARS
101112
idp_login_service_user_token = "ServiceUserTokenValue"
102113
ipd_login_github_webhook_secret = "GitHubWebhookAuthToken"
114+
gc_template_id = "0123456789"
103115
}
104116

105117
include "root" {

0 commit comments

Comments
 (0)