Skip to content

Commit 91d7de9

Browse files
committed
Build Stalwart log group; give instances write access
1 parent 68408cd commit 91d7de9

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

pulumi/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __stalwart_cluster(jumphost_rules: list[dict]):
8282
return stalwart.StalwartCluster(
8383
f'{project.name_prefix}-stalwart',
8484
project=project,
85+
log_group_arn=logdests['stalwart'].resources['iam_policies']['write'].arn,
8586
private_subnets=vpc.resources['private_subnets'],
8687
public_subnets=vpc.resources['public_subnets'],
8788
node_additional_ingress_rules=jumphost_rules,

pulumi/config.dev.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ resources:
88
- stalwart.postboot.keycloak_backend
99
recovery_window_in_days: 0
1010

11+
tb:cloudwatch:LogDestination:
12+
stalwart:
13+
log_group:
14+
retention_in_days: 7
15+
log_streams:
16+
api: api
17+
mail: mail
18+
org_name: tb
19+
1120
tb:network:MultiTierVpc:
1221
vpc:
1322
cidr_block: 10.2.0.0/16

pulumi/stalwart/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def __init__(
274274
self,
275275
name: str,
276276
project: tb_pulumi.ThunderbirdPulumiProject,
277+
log_group_arn: str,
277278
private_subnets: list[aws.ec2.Subnet],
278279
public_subnets: list[aws.ec2.Subnet],
279280
https_features: list = [],
@@ -343,8 +344,16 @@ def __init__(
343344
s3_bucket, s3_secret, s3_policy = stalwart_s3.s3(self=self)
344345

345346
# Build an IAM role with a policy to enable node bootstrapping
346-
profile_policy, role, profile_postboot_attachment, profile_s3_attachment, profile = stalwart_iam.iam(
347+
(
348+
profile_policy,
349+
role,
350+
profile_postboot_attachment,
351+
profile_s3_attachment,
352+
profile_logwrite_attachment,
353+
profile,
354+
) = stalwart_iam.iam(
347355
self,
356+
log_group_arn=log_group_arn,
348357
s3_policy=s3_policy,
349358
)
350359

@@ -463,6 +472,7 @@ def __init__(
463472
'spam_filter_secret': config_secrets['spam_filter'],
464473
'node_profile': profile,
465474
'node_profile_policy': profile_policy,
475+
'node_profile_logwrite_attachment': profile_logwrite_attachment,
466476
'node_profile_postboot_policy_attachment': profile_postboot_attachment,
467477
'node_profile_s3_policy_attachment': profile_s3_attachment,
468478
'node_sgs': self.node_sgs,

pulumi/stalwart/iam.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
def iam(
1212
self,
13+
log_group_arn: str,
1314
s3_policy: aws.iam.Policy,
1415
) -> tuple[
1516
aws.iam.Policy, aws.iam.Role, aws.iam.RolePolicyAttachment, aws.iam.RolePolicyAttachment, aws.iam.InstanceProfile
@@ -32,14 +33,18 @@ def iam(
3233
+ f':secret:mailstrom/{self.project.stack}/stalwart.postboot.*'
3334
),
3435
]
35-
profile_postboot_policy_doc = IAM_POLICY_DOCUMENT.copy()
36-
profile_postboot_policy_doc['Statement'][0].update(
37-
{
38-
'Sid': 'AllowPostbootSecretAccess',
39-
'Action': ['secretsmanager:GetSecretValue'],
40-
'Resource': bootstrap_secret_arns,
41-
}
42-
)
36+
profile_postboot_policy_doc = {
37+
'Version': '2012-10-17',
38+
'Statement': [
39+
{
40+
'Sid': 'AllowPostbootSecretAccess',
41+
'Effect': 'Allow',
42+
'Action': ['secretsmanager:GetSecretValue'],
43+
'Resource': bootstrap_secret_arns,
44+
}
45+
],
46+
}
47+
4348
profile_policy = aws.iam.Policy(
4449
f'{self.name}-policy-nodeprofile',
4550
path='/',
@@ -64,7 +69,19 @@ def iam(
6469
role=role.name,
6570
policy_arn=s3_policy.arn,
6671
)
72+
profile_logwrite_attachment = aws.iam.RolePolicyAttachment(
73+
f'{self.name}-rpa-nodeprofile-logs',
74+
role=role.name,
75+
policy_arn=log_group_arn,
76+
)
6777

6878
profile = aws.iam.InstanceProfile(f'{self.name}-ip-nodeprofile', name=f'{self.name}-nodeprofile', role=role.name)
6979

70-
return profile_policy, role, profile_postboot_attachment, profile_s3_attachment, profile
80+
return (
81+
profile_policy,
82+
role,
83+
profile_postboot_attachment,
84+
profile_s3_attachment,
85+
profile_logwrite_attachment,
86+
profile,
87+
)

0 commit comments

Comments
 (0)