saaslayer 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -16
- package/bin/saaslayer.js +387 -61
- package/package.json +3 -2
- package/src/api-client.js +37 -1
- package/src/aws-sigv4.js +74 -26
- package/src/cognito-user-api.js +80 -0
- package/src/commands/access-admins.js +2 -2
- package/src/commands/account-email.js +43 -0
- package/src/commands/admin-allowlist.js +65 -0
- package/src/commands/api-keys.js +83 -0
- package/src/commands/audit.js +77 -0
- package/src/commands/aws.js +355 -82
- package/src/commands/binding-handoff.js +174 -0
- package/src/commands/bindings.js +111 -0
- package/src/commands/catalog.js +30 -3
- package/src/commands/deploy.js +33 -10
- package/src/commands/env-export.js +58 -0
- package/src/commands/first-admin.js +15 -4
- package/src/commands/foundation.js +75 -117
- package/src/commands/hooks.js +271 -0
- package/src/commands/integration-credentials.js +1 -1
- package/src/commands/lifecycle.js +149 -24
- package/src/commands/login-domain.js +259 -0
- package/src/commands/login.js +53 -16
- package/src/commands/org-members.js +109 -0
- package/src/commands/permission-orgs.js +80 -0
- package/src/commands/release-manifest.js +17 -8
- package/src/commands/service-principals.js +42 -5
- package/src/commands/settings.js +21 -5
- package/src/commands/sms-registration.js +182 -0
- package/src/commands/sms.js +178 -0
- package/src/commands/social.js +265 -0
- package/src/commands/support-staff.js +72 -0
- package/src/commands/trust-policies.js +172 -0
- package/src/commands/users-management.js +2 -20
- package/src/commands/users.js +56 -11
- package/src/commands/versions.js +61 -0
- package/src/connection-proof.js +41 -0
- package/src/deployment-api-auth.js +166 -8
- package/src/deployments.js +1 -1
- package/src/foundation-change-set.js +180 -0
- package/src/foundation-home.js +121 -0
- package/src/foundation-template.js +51 -10
- package/src/foundation-trust-write.js +379 -0
- package/src/iam-session.js +14 -8
- package/src/login-domain.js +139 -0
- package/src/login-methods.js +118 -0
- package/src/module-catalog.js +3 -2
- package/src/permissions-request.js +15 -9
- package/src/release-manifest.js +11 -4
- package/src/scope.js +3 -1
- package/src/settings.js +85 -13
- package/src/sms/number.js +37 -0
- package/src/sms/registration-fields.js +167 -0
- package/src/sms/registration-validate.js +151 -0
- package/src/sms/registration.js +216 -0
- package/src/sms/release.js +55 -0
- package/src/sms/scope.js +86 -0
- package/src/sms/status.js +181 -0
- package/src/ssm-api.js +31 -0
- package/src/trust-entries.js +350 -0
- package/src/user-service-instance.js +27 -0
- package/src/users-api.js +55 -8
- package/src/users-import/checkpoint.js +76 -0
- package/src/users-import/import.js +233 -24
- package/src/versions.js +80 -0
- package/templates/saaslayer-foundation-region.yml +45 -1
- package/templates/saaslayer-foundation.yml +747 -296
|
@@ -10,27 +10,46 @@
|
|
|
10
10
|
#
|
|
11
11
|
# SECURITY REVIEWER SUMMARY
|
|
12
12
|
#
|
|
13
|
-
# This template creates one S3 bucket, one permissions-boundary managed policy,
|
|
13
|
+
# This template creates one S3 bucket, one permissions-boundary managed policy, one managed policy attached to the
|
|
14
|
+
# execution role (sl-foundation-cfn-exec-policy), and three IAM roles:
|
|
14
15
|
#
|
|
15
|
-
# 1. SaaSLayerDeploymentRole — the only cross-account WRITE entry point.
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# 1. SaaSLayerDeploymentRole — the only cross-account WRITE entry point. Its trust is rendered from
|
|
17
|
+
# the TrustEntries parameter: one statement per managing control plane, each naming only that
|
|
18
|
+
# control plane's account, its deploy identity role (aws:PrincipalArn) and its trust identifiers
|
|
19
|
+
# (sts:ExternalId). It can drive the CloudFormation lifecycle of stacks whose names start with
|
|
18
20
|
# StackNamePrefix (default "sl-"), read/write the deployment artifact buckets, update the
|
|
19
21
|
# configuration of StackNamePrefix functions (credential hot-swap), and pass exactly
|
|
20
22
|
# one role (SaaSLayerCloudFormationExecutionRole) to CloudFormation. It cannot create IAM
|
|
21
|
-
# resources
|
|
23
|
+
# resources. Its direct writes reach only StackNamePrefix-named resources (stacks, buckets, tables,
|
|
24
|
+
# functions, log groups, secrets) or resources carrying managed-by=saaslayer-deployer (user pools,
|
|
25
|
+
# KMS keys, ACM certificates, API Gateway custom domains and REST API stages, native-edge CloudFront
|
|
26
|
+
# distributions); it creates certificates, custom domains and distributions only carrying that tag.
|
|
27
|
+
# It may import resources into a stack only through the
|
|
28
|
+
# retained-resource adoption change set (saaslayer-adopt-*) and only the types adoption handles. It
|
|
29
|
+
# also writes /saaslayer/deployment/* SSM parameters (deployment handoff values). Its only
|
|
22
30
|
# sts:AssumeRole grant is into a module stack's own data-migration role
|
|
23
|
-
# (role/${StackNamePrefix}*-migrate), whose policy limits it to that service's tables.
|
|
31
|
+
# (role/${StackNamePrefix}*-migrate), whose policy limits it to that service's tables. It may read
|
|
32
|
+
# exactly one SSM parameter under /saaslayer/foundation: connection-authorizers (below).
|
|
24
33
|
#
|
|
25
34
|
# 2. SaaSLayerCloudFormationExecutionRole — assumable ONLY by the CloudFormation service, never
|
|
26
35
|
# cross-account. CloudFormation uses it to create/update/delete the resources declared by
|
|
27
36
|
# approved SaaSLayer module templates. Its permissions are the provisioning verbs derived from
|
|
28
|
-
# the module resource inventory (see per-statement comments below).
|
|
29
|
-
#
|
|
30
|
-
#
|
|
37
|
+
# the module resource inventory (see per-statement comments below). Buckets, tables, functions,
|
|
38
|
+
# topics, KMS aliases, IAM roles/policies, SMS configuration sets, alarms, dashboards, event buses
|
|
39
|
+
# and rules, log groups, schedules, SSM parameters, queues and CloudFront functions are scoped to
|
|
40
|
+
# StackNamePrefix names (the alarm-to-queue grants sit in sl-foundation-cfn-exec-policy, attached
|
|
41
|
+
# to this role); user pools, identity pools, KMS keys, CloudFront distributions and secrets to
|
|
42
|
+
# resources carrying managed-by=saaslayer-deployer (created only carrying it, and managed-by can never
|
|
43
|
+
# be added to a user pool that lacks it); API Gateway to the API paths (never custom domains,
|
|
44
|
+
# mappings, the account or VPC links). CloudFront origin access controls (id ARNs, no condition keys)
|
|
45
|
+
# still take Resource '*', as do the Cognito log-delivery verbs and the identity pool role
|
|
46
|
+
# attachment, which take no resource.
|
|
47
|
+
# Because only SaaSLayerDeploymentRole can pass this role, it is reachable exclusively through the
|
|
48
|
+
# audited stack lifecycle above.
|
|
31
49
|
#
|
|
32
50
|
# 3. SaaSLayerSupportReadOnlyRole — a separate cross-account READ-ONLY role for SaaSLayer support
|
|
33
|
-
# staff.
|
|
51
|
+
# staff. Trust rendered from TrustEntries like the deployment role (each control plane's support
|
|
52
|
+
# identity role + trust identifiers), plus an enforced
|
|
34
53
|
# "saaslayer-support-*" session-name pattern so every assumption is attributable in CloudTrail.
|
|
35
54
|
# It carries only Get/List/Describe verbs, is tag-scoped to resources carrying
|
|
36
55
|
# managed-by=saaslayer-deployer where IAM supports resource-tag conditions, and deliberately
|
|
@@ -38,6 +57,15 @@
|
|
|
38
57
|
# values, no Secrets Manager secret values, no function code downloads). An explicit Deny
|
|
39
58
|
# (DenySecretValueReads) covers the /saaslayer/deployment/* SecureStrings and their KMS decrypt.
|
|
40
59
|
#
|
|
60
|
+
# SaaSLayerConnectionAuthorizers is an SSM String parameter publishing ConnectionAuthorizerArns and the
|
|
61
|
+
# control-plane ids in TrustEntries, so a control plane can read who may authorize connections through
|
|
62
|
+
# the deployment role. It holds no secret.
|
|
63
|
+
#
|
|
64
|
+
# TRUST RENDERING: CloudFormation cannot parse JSON, so the SaaSLayer CLI renders the trust statements
|
|
65
|
+
# from TrustEntries into this template before submitting it: each entry role's Statement line below is a
|
|
66
|
+
# single-line JSON flow sequence (empty here, filled at deploy time), and the SSM value's controlPlanes
|
|
67
|
+
# literal is filled the same way. Trust-only edits replace only those lines of the INSTALLED template.
|
|
68
|
+
#
|
|
41
69
|
# SaaSLayerManagedResourceBoundary is a permissions boundary attached to every IAM role that
|
|
42
70
|
# SaaSLayer module templates create: whatever a module role's own policy says, its effective
|
|
43
71
|
# runtime permissions can never exceed this boundary.
|
|
@@ -46,11 +74,11 @@
|
|
|
46
74
|
# deploymentId, customerId, and moduleName for inventory and audit.
|
|
47
75
|
#
|
|
48
76
|
# Contract tests for this template live at tests/bootstrap.test.js (read-only guarantee for the
|
|
49
|
-
# support role,
|
|
77
|
+
# support role, rendered trust-statement enforcement, wildcard justification audit).
|
|
50
78
|
AWSTemplateFormatVersion: '2010-09-09'
|
|
51
79
|
Description: >-
|
|
52
|
-
SaaSLayer foundation stack: grants
|
|
53
|
-
to deploy and support SaaSLayer modules in this account. Installed once per account. Details:
|
|
80
|
+
SaaSLayer foundation stack: grants each managing SaaSLayer control plane listed in TrustEntries scoped,
|
|
81
|
+
trust-identifier-gated access to deploy and support SaaSLayer modules in this account. Installed once per account. Details:
|
|
54
82
|
https://saaslayer.com/docs/account-access
|
|
55
83
|
|
|
56
84
|
Parameters:
|
|
@@ -58,14 +86,21 @@ Parameters:
|
|
|
58
86
|
Type: String
|
|
59
87
|
AllowedPattern: '^[0-9]{12}$'
|
|
60
88
|
Description: >-
|
|
61
|
-
AWS account ID
|
|
62
|
-
|
|
63
|
-
|
|
89
|
+
AWS account ID of the control plane that first connected this account. Informational only: trust
|
|
90
|
+
is rendered from TrustEntries, which names each managing control plane's own account.
|
|
91
|
+
TrustEntries:
|
|
64
92
|
Type: String
|
|
65
|
-
|
|
93
|
+
MaxLength: 4096
|
|
66
94
|
Description: >-
|
|
67
|
-
|
|
68
|
-
|
|
95
|
+
JSON array of trust entries, one per managing SaaSLayer control plane (v 1): controlPlaneId,
|
|
96
|
+
principalAccountId, trustIdentifiers, deployCallerArns, supportCallerArns. The SaaSLayer CLI renders
|
|
97
|
+
the entry roles' trust statements from it. Trust identifiers are AWS ExternalIds, not secrets.
|
|
98
|
+
ConnectionAuthorizerArns:
|
|
99
|
+
Type: CommaDelimitedList
|
|
100
|
+
Description: >-
|
|
101
|
+
IAM principal ARNs (path-less role ARNs) permitted to authorize SaaSLayer org connections to this
|
|
102
|
+
account. Defaults to the principal that first deploys this stack; changed only by an explicit
|
|
103
|
+
authorizer update.
|
|
69
104
|
StackNamePrefix:
|
|
70
105
|
Type: String
|
|
71
106
|
Default: sl-
|
|
@@ -115,7 +150,7 @@ Mappings:
|
|
|
115
150
|
# patch = comments/docs/no behavior change
|
|
116
151
|
Meta:
|
|
117
152
|
Foundation:
|
|
118
|
-
Version: '
|
|
153
|
+
Version: '8.0.0'
|
|
119
154
|
|
|
120
155
|
Resources:
|
|
121
156
|
# The shared deployment-artifact bucket moved OUT of this account-global stack into the per-region
|
|
@@ -141,6 +176,8 @@ Resources:
|
|
|
141
176
|
Principal:
|
|
142
177
|
Service: cloudformation.amazonaws.com
|
|
143
178
|
Action: sts:AssumeRole
|
|
179
|
+
ManagedPolicyArns:
|
|
180
|
+
- !Ref SaaSLayerCloudFormationExecutionPolicy
|
|
144
181
|
Policies:
|
|
145
182
|
- PolicyName: saaslayer-approved-template-execution
|
|
146
183
|
PolicyDocument:
|
|
@@ -149,99 +186,54 @@ Resources:
|
|
|
149
186
|
# Provisioning verbs per service. Several AWS create/list APIs only accept
|
|
150
187
|
# Resource '*'; resource-name namespacing work to tighten this is tracked in
|
|
151
188
|
# docs/permissions-hardening.md.
|
|
189
|
+
# Services scoped by the managed name prefix or the managed-by tag have their own statements below
|
|
190
|
+
# (alarms, event buses and rules, log groups, schedules, parameters and queues in
|
|
191
|
+
# sl-foundation-cfn-exec-policy). What stays on Resource '*' is reads, creates that take no resource
|
|
192
|
+
# ARN, verbs AWS defines with no resource type, and services not yet scoped (UNSCOPED_PENDING_ON_STAR
|
|
193
|
+
# in tests/bootstrap.test.js, which may only shrink).
|
|
152
194
|
- Effect: Allow
|
|
153
195
|
Action:
|
|
154
|
-
# API Gateway IAM actions are bare HTTP verbs against untyped resource paths;
|
|
155
|
-
# REST API provisioning (methods, resources, deployments, stages, authorizers)
|
|
156
|
-
# exercises all of them. Justified service wildcard (tests/bootstrap.test.js).
|
|
157
|
-
- apigateway:*
|
|
158
196
|
# Stack introspection while executing changesets (read-only verbs).
|
|
159
197
|
- cloudformation:Describe*
|
|
160
198
|
- cloudformation:Get*
|
|
161
199
|
- cloudformation:List*
|
|
162
|
-
# CloudWatch alarm + dashboard
|
|
163
|
-
-
|
|
164
|
-
- cloudwatch:DeleteDashboards
|
|
200
|
+
# CloudWatch alarm + dashboard reads for module observability resources. Lifecycle:
|
|
201
|
+
# sl-foundation-cfn-exec-policy (managed prefix).
|
|
165
202
|
- cloudwatch:DescribeAlarms
|
|
166
|
-
- cloudwatch:DisableAlarmActions
|
|
167
|
-
- cloudwatch:EnableAlarmActions
|
|
168
203
|
- cloudwatch:GetDashboard
|
|
169
204
|
- cloudwatch:ListDashboards
|
|
170
205
|
# DetectStackDrift reads alarm tags; without this, drift checks on the ops alarms
|
|
171
206
|
# 403 and block every UPDATE (fail-closed drift gate).
|
|
172
207
|
- cloudwatch:ListTagsForResource
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
#
|
|
178
|
-
|
|
179
|
-
# resource-scoped, so these sit in the Resource:'*' statement. CreateInvalidation
|
|
180
|
-
# busts the edge cache when a redeploy uploads a new SPA build.
|
|
181
|
-
- cloudfront:CreateDistribution
|
|
208
|
+
# Origin access control lifecycle for static-site modules (frontend-hosting, permissions-admin-ui:
|
|
209
|
+
# private S3 origin + OAC): *OriginAccessControl is its Create/Get/Update/Delete (template size). An OAC
|
|
210
|
+
# ARN carries an id and AWS defines no condition key for it, so neither a name nor a tag can scope it.
|
|
211
|
+
# CreateInvalidation busts the edge cache when a redeploy uploads a new SPA build. Distribution
|
|
212
|
+
# lifecycle: tag-scoped statements below.
|
|
213
|
+
- cloudfront:*OriginAccessControl
|
|
182
214
|
- cloudfront:CreateInvalidation
|
|
183
|
-
- cloudfront:
|
|
184
|
-
- cloudfront:DeleteDistribution
|
|
185
|
-
- cloudfront:DeleteOriginAccessControl
|
|
186
|
-
- cloudfront:GetDistribution
|
|
187
|
-
- cloudfront:GetDistributionConfig
|
|
188
|
-
- cloudfront:GetOriginAccessControl
|
|
215
|
+
- cloudfront:GetDistribution*
|
|
189
216
|
- cloudfront:ListTagsForResource
|
|
190
|
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
193
|
-
-
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- sns:CreateTopic
|
|
198
|
-
- sns:DeleteTopic
|
|
199
|
-
- sns:GetTopicAttributes
|
|
200
|
-
- sns:SetTopicAttributes
|
|
201
|
-
- sns:Subscribe
|
|
202
|
-
- sns:Unsubscribe
|
|
203
|
-
- sns:ListSubscriptionsByTopic
|
|
204
|
-
- sns:TagResource
|
|
205
|
-
- sns:UntagResource
|
|
206
|
-
# Cognito identity pool + user pool lifecycle (user-service module). Their
|
|
207
|
-
# CloudFormation handlers exercise a broad, shifting action set; kept as
|
|
208
|
-
# justified service wildcards until enumerated (docs/permissions-hardening.md).
|
|
209
|
-
- cognito-identity:*
|
|
210
|
-
- cognito-idp:*
|
|
211
|
-
# DynamoDB table lifecycle (provisioning verbs only — no item read/write).
|
|
212
|
-
- dynamodb:CreateTable
|
|
213
|
-
- dynamodb:DeleteTable
|
|
214
|
-
- dynamodb:DescribeContinuousBackups
|
|
215
|
-
- dynamodb:DescribeContributorInsights
|
|
216
|
-
- dynamodb:DescribeTable
|
|
217
|
-
- dynamodb:DescribeTimeToLive
|
|
218
|
-
- dynamodb:ListTagsOfResource
|
|
219
|
-
- dynamodb:TagResource
|
|
220
|
-
- dynamodb:UntagResource
|
|
221
|
-
- dynamodb:UpdateContinuousBackups
|
|
222
|
-
- dynamodb:UpdateContributorInsights
|
|
223
|
-
- dynamodb:UpdateTable
|
|
224
|
-
- dynamodb:UpdateTimeToLive
|
|
217
|
+
# Identity pool calls that take no pool ARN: the pool list and the role attachment (user-service
|
|
218
|
+
# IdentityPoolRoleAttachment). Pool lifecycle: tag-scoped statements below.
|
|
219
|
+
- cognito-identity:ListIdentityPools
|
|
220
|
+
- cognito-identity:SetIdentityPoolRoles
|
|
221
|
+
# User-pool reads that take no resource ARN.
|
|
222
|
+
- cognito-idp:DescribeUserPoolDomain
|
|
223
|
+
- cognito-idp:ListUserPools
|
|
225
224
|
# EventBridge custom event bus lifecycle (module event buses) + rule lifecycle for
|
|
226
225
|
# scheduled Lambdas (serverless `schedule` events generate AWS::Events::Rule — e.g.
|
|
227
226
|
# rbac-service's event-delivery poller). DescribeRule/PutRule/*Targets are required
|
|
228
|
-
# or the rule CREATE fails with AccessDenied.
|
|
229
|
-
- events:CreateEventBus
|
|
230
|
-
- events:DeleteEventBus
|
|
231
|
-
- events:DeleteRule
|
|
227
|
+
# or the rule CREATE fails with AccessDenied. Reads here; lifecycle: sl-foundation-cfn-exec-policy.
|
|
232
228
|
- events:DescribeEventBus
|
|
233
229
|
- events:DescribeRule
|
|
234
|
-
- events:DisableRule
|
|
235
|
-
- events:EnableRule
|
|
236
230
|
- events:ListTagsForResource
|
|
237
231
|
- events:ListTargetsByRule
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
- events:TagResource
|
|
244
|
-
- events:UntagResource
|
|
232
|
+
# EarlyValidation runs a KMS::Alias name-conflict check on change-set creation; without
|
|
233
|
+
# ListAliases it reports a (non-fatal) "not allowed to check if resource already exists"
|
|
234
|
+
# FAIL in the console Hooks view and can't detect a real alias collision. Enumeration API,
|
|
235
|
+
# no resource-level scoping (monorepo-pcren). Key and alias lifecycle: tag/prefix-scoped statements below.
|
|
236
|
+
- kms:ListAliases
|
|
245
237
|
# IAM read-only introspection during changeset execution. Mutating IAM verbs
|
|
246
238
|
# (Create/Delete/Update/Attach/Pass/Tag) are prefix-scoped in dedicated
|
|
247
239
|
# statements below — never Resource '*' — and CreateRole additionally requires
|
|
@@ -254,202 +246,274 @@ Resources:
|
|
|
254
246
|
- iam:ListEntitiesForPolicy
|
|
255
247
|
- iam:ListPolicyVersions
|
|
256
248
|
- iam:ListRolePolicies
|
|
257
|
-
#
|
|
258
|
-
#
|
|
259
|
-
# encryption; CreateKey mandates Resource '*', and TagResource on the new key
|
|
260
|
-
# is required or CloudFormation fails with UnauthorizedTaggingOperation.
|
|
261
|
-
- kms:CreateAlias
|
|
262
|
-
- kms:CreateKey
|
|
263
|
-
# EarlyValidation runs a KMS::Alias name-conflict check on change-set creation; without
|
|
264
|
-
# ListAliases it reports a (non-fatal) "not allowed to check if resource already exists"
|
|
265
|
-
# FAIL in the console Hooks view and can't detect a real alias collision. Enumeration API,
|
|
266
|
-
# no resource-level scoping (monorepo-pcren).
|
|
267
|
-
- kms:ListAliases
|
|
268
|
-
# Grant + data-plane actions: a resource encrypted with a customer CMK (email-inbound's
|
|
269
|
-
# InboundTable via DynamoDB SSE-KMS) makes the service create a grant AND
|
|
270
|
-
# decrypt/generate data keys against the CMK during provisioning — without these the
|
|
271
|
-
# table create fails AccessDenied (kms:CreateGrant, then kms:Decrypt/GenerateDataKey).
|
|
272
|
-
- kms:CreateGrant
|
|
273
|
-
- kms:Decrypt
|
|
274
|
-
- kms:DeleteAlias
|
|
275
|
-
- kms:DescribeKey
|
|
276
|
-
- kms:DisableKeyRotation
|
|
277
|
-
- kms:EnableKeyRotation
|
|
278
|
-
- kms:Encrypt
|
|
279
|
-
- kms:GenerateDataKey
|
|
280
|
-
- kms:GenerateDataKeyWithoutPlaintext
|
|
281
|
-
- kms:GetKeyPolicy
|
|
282
|
-
- kms:GetKeyRotationStatus
|
|
283
|
-
- kms:ListGrants
|
|
284
|
-
- kms:ListResourceTags
|
|
285
|
-
- kms:PutKeyPolicy
|
|
286
|
-
- kms:ReEncryptFrom
|
|
287
|
-
- kms:ReEncryptTo
|
|
288
|
-
- kms:RevokeGrant
|
|
289
|
-
- kms:ScheduleKeyDeletion
|
|
290
|
-
- kms:TagResource
|
|
291
|
-
- kms:UntagResource
|
|
292
|
-
- kms:UpdateAlias
|
|
293
|
-
# Lambda function/layer/alias/event-source lifecycle. lambda:InvokeFunction is
|
|
294
|
-
# required because module templates use CloudFormation custom resources
|
|
295
|
-
# (Custom::Delay in user-service) that CloudFormation invokes during deploys.
|
|
296
|
-
- lambda:AddPermission
|
|
249
|
+
# Lambda calls that take no function ARN (event-source-mapping create, account and list reads).
|
|
250
|
+
# Function lifecycle: the managed-prefix statement below.
|
|
297
251
|
- lambda:CreateEventSourceMapping
|
|
298
|
-
- lambda:CreateFunction
|
|
299
|
-
- lambda:DeleteEventSourceMapping
|
|
300
|
-
- lambda:DeleteFunction
|
|
301
|
-
- lambda:DeleteFunctionConcurrency
|
|
302
|
-
- lambda:DeleteFunctionEventInvokeConfig
|
|
303
|
-
- lambda:DeleteLayerVersion
|
|
304
|
-
- lambda:DeleteProvisionedConcurrencyConfig
|
|
305
252
|
- lambda:GetAccountSettings
|
|
306
|
-
- lambda:GetAlias
|
|
307
253
|
- lambda:GetEventSourceMapping
|
|
308
|
-
- lambda:GetFunction
|
|
309
|
-
- lambda:GetFunctionCodeSigningConfig
|
|
310
|
-
- lambda:GetFunctionConcurrency
|
|
311
|
-
- lambda:GetFunctionConfiguration
|
|
312
|
-
- lambda:GetFunctionEventInvokeConfig
|
|
313
|
-
- lambda:GetLayerVersion
|
|
314
|
-
- lambda:GetPolicy
|
|
315
|
-
- lambda:GetProvisionedConcurrencyConfig
|
|
316
|
-
- lambda:GetRuntimeManagementConfig
|
|
317
|
-
- lambda:InvokeFunction
|
|
318
|
-
- lambda:ListAliases
|
|
319
254
|
- lambda:ListEventSourceMappings
|
|
320
255
|
- lambda:ListFunctions
|
|
321
256
|
- lambda:ListLayerVersions
|
|
322
|
-
|
|
323
|
-
- lambda:ListVersionsByFunction
|
|
324
|
-
- lambda:PublishLayerVersion
|
|
325
|
-
- lambda:PublishVersion
|
|
326
|
-
- lambda:PutFunctionCodeSigningConfig
|
|
327
|
-
- lambda:PutFunctionConcurrency
|
|
328
|
-
- lambda:PutFunctionEventInvokeConfig
|
|
329
|
-
- lambda:PutProvisionedConcurrencyConfig
|
|
330
|
-
- lambda:RemovePermission
|
|
331
|
-
- lambda:TagResource
|
|
332
|
-
- lambda:UntagResource
|
|
333
|
-
- lambda:UpdateAlias
|
|
334
|
-
- lambda:UpdateEventSourceMapping
|
|
335
|
-
- lambda:UpdateFunctionCode
|
|
336
|
-
- lambda:UpdateFunctionConfiguration
|
|
337
|
-
# Log group lifecycle for module functions/services. The LogDelivery and
|
|
257
|
+
# Log group reads for module functions/services. The LogDelivery and
|
|
338
258
|
# resource-policy verbs support AWS::Cognito::LogDeliveryConfiguration
|
|
339
|
-
# (user-service auth event logging).
|
|
259
|
+
# (user-service auth event logging) and take no resource ARN. Log group and metric filter
|
|
260
|
+
# (billing-service ops alarms on its log events) lifecycle: sl-foundation-cfn-exec-policy.
|
|
340
261
|
- logs:CreateLogDelivery
|
|
341
|
-
- logs:CreateLogGroup
|
|
342
|
-
- logs:CreateLogStream
|
|
343
262
|
- logs:DeleteLogDelivery
|
|
344
|
-
- logs:DeleteLogGroup
|
|
345
|
-
- logs:DeleteLogStream
|
|
346
|
-
- logs:DeleteRetentionPolicy
|
|
347
263
|
- logs:DescribeIndexPolicies
|
|
348
264
|
- logs:DescribeLogGroups
|
|
349
265
|
- logs:DescribeLogStreams
|
|
266
|
+
- logs:DescribeMetricFilters
|
|
350
267
|
- logs:DescribeResourcePolicies
|
|
351
268
|
- logs:GetLogDelivery
|
|
352
269
|
- logs:ListLogDeliveries
|
|
353
270
|
- logs:ListTagsForResource
|
|
354
|
-
- logs:PutDestination
|
|
355
|
-
- logs:PutDestinationPolicy
|
|
356
|
-
- logs:PutLogEvents
|
|
357
271
|
- logs:PutResourcePolicy
|
|
358
|
-
- logs:PutRetentionPolicy
|
|
359
|
-
- logs:TagLogGroup
|
|
360
|
-
- logs:TagResource
|
|
361
|
-
- logs:UntagLogGroup
|
|
362
|
-
- logs:UntagResource
|
|
363
272
|
- logs:UpdateLogDelivery
|
|
364
|
-
# EventBridge Scheduler
|
|
365
|
-
# delegation expiry uses schedules; runtime CRUD is granted via the boundary).
|
|
366
|
-
-
|
|
367
|
-
- scheduler:CreateScheduleGroup
|
|
368
|
-
- scheduler:DeleteSchedule
|
|
369
|
-
- scheduler:DeleteScheduleGroup
|
|
273
|
+
# EventBridge Scheduler reads for module-declared schedules (rbac-core
|
|
274
|
+
# delegation expiry uses schedules; runtime CRUD is granted via the boundary). Lifecycle:
|
|
275
|
+
# sl-foundation-cfn-exec-policy.
|
|
370
276
|
- scheduler:GetSchedule
|
|
371
277
|
- scheduler:GetScheduleGroup
|
|
372
278
|
- scheduler:ListTagsForResource
|
|
373
|
-
-
|
|
374
|
-
- scheduler:UntagResource
|
|
375
|
-
- scheduler:UpdateSchedule
|
|
376
|
-
# Secrets Manager secret lifecycle (AWS::SecretsManager::Secret in modules).
|
|
377
|
-
# No GetSecretValue: this role provisions secrets, it cannot read their values.
|
|
378
|
-
- secretsmanager:CreateSecret
|
|
379
|
-
- secretsmanager:DeleteResourcePolicy
|
|
380
|
-
- secretsmanager:DeleteSecret
|
|
279
|
+
# Secret metadata reads. Lifecycle: tag-scoped statements below.
|
|
381
280
|
- secretsmanager:DescribeSecret
|
|
382
281
|
- secretsmanager:GetResourcePolicy
|
|
383
|
-
|
|
282
|
+
# SSM parameter reads for module configuration exports (AWS::SSM::Parameter). Lifecycle:
|
|
283
|
+
# sl-foundation-cfn-exec-policy.
|
|
284
|
+
- ssm:DescribeParameters
|
|
285
|
+
- ssm:GetParameter
|
|
286
|
+
- ssm:GetParameters
|
|
287
|
+
- ssm:GetParametersByPath
|
|
288
|
+
- ssm:ListTagsForResource
|
|
289
|
+
# SQS queue reads. Lifecycle: sl-foundation-cfn-exec-policy.
|
|
290
|
+
- sqs:GetQueueAttributes
|
|
291
|
+
- sqs:ListQueueTags
|
|
292
|
+
Resource: '*'
|
|
293
|
+
# API Gateway IAM actions are bare HTTP verbs against untyped resource paths; REST, HTTP and
|
|
294
|
+
# WebSocket API provisioning (methods, resources, deployments, stages, authorizers, routes,
|
|
295
|
+
# integrations) exercises all of them. Justified service wildcard (tests/bootstrap.test.js), limited
|
|
296
|
+
# to the API paths and their tags: no module declares a custom domain, base path / API mapping, the
|
|
297
|
+
# account CloudWatch role, a VPC link or a usage plan, so those paths are out of reach. API ids
|
|
298
|
+
# carry no name, and osls tags HTTP APIs only on request, so no prefix or tag condition applies here.
|
|
299
|
+
- Effect: Allow
|
|
300
|
+
Action:
|
|
301
|
+
- apigateway:*
|
|
302
|
+
Resource:
|
|
303
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/restapis
|
|
304
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/restapis/*
|
|
305
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/apis
|
|
306
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/apis/*
|
|
307
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/tags/*
|
|
308
|
+
# Cognito user and identity pools (user-service), CloudFront distributions (frontend-hosting,
|
|
309
|
+
# permissions-admin-ui) and secrets (user-service's PasswordlessMagicLinkHmacSecret, named by CloudFormation
|
|
310
|
+
# <LogicalId>-<random>, outside the managed prefix). Pool and distribution ARNs carry ids and the secret's name
|
|
311
|
+
# is not ours, so the managed-by tag scopes all four: created only carrying managed-by=saaslayer-deployer
|
|
312
|
+
# (user-service sets it in UserPoolTags, IdentityPoolTags and the secret's Tags; the modules' stack tags reach
|
|
313
|
+
# distributions and secrets), then changed only while they carry it. The pool and distribution create APIs take no resource
|
|
314
|
+
# ARN. Tags at create need TagResource with the request carrying managed-by; that grant could also stamp
|
|
315
|
+
# managed-by on an existing distribution, identity pool or secret, which this role reaches only through its
|
|
316
|
+
# own stacks (imports are limited to the adoption change set). User pools are guarded by the Deny below.
|
|
317
|
+
- Effect: Allow
|
|
318
|
+
Action:
|
|
319
|
+
- cloudfront:CreateDistribution
|
|
320
|
+
- cloudfront:TagResource
|
|
321
|
+
- cognito-identity:CreateIdentityPool
|
|
322
|
+
- cognito-identity:TagResource
|
|
323
|
+
- cognito-idp:CreateUserPool
|
|
324
|
+
- secretsmanager:CreateSecret
|
|
325
|
+
- secretsmanager:TagResource
|
|
326
|
+
Resource: '*'
|
|
327
|
+
Condition:
|
|
328
|
+
StringEquals:
|
|
329
|
+
aws:RequestTag/managed-by: saaslayer-deployer
|
|
330
|
+
# Each action matches only its own service's ARNs. The pool CloudFormation handlers exercise a broad,
|
|
331
|
+
# shifting action set, so the service wildcards stay, limited to tagged pools. No GetSecretValue: this role
|
|
332
|
+
# provisions secrets, it cannot read their values. *TagResource is TagResource and UntagResource.
|
|
333
|
+
- Effect: Allow
|
|
334
|
+
Action:
|
|
335
|
+
- cloudfront:*TagResource
|
|
336
|
+
- cloudfront:DeleteDistribution
|
|
337
|
+
- cloudfront:UpdateDistribution
|
|
338
|
+
- cognito-identity:*
|
|
339
|
+
- cognito-idp:*
|
|
340
|
+
# Secret verbs as globs (inline policy and template size): *Replica* is RemoveRegionsFromReplication,
|
|
341
|
+
# ReplicateSecretToRegions and StopReplicationToReplica; Update* is UpdateSecret and
|
|
342
|
+
# UpdateSecretVersionStage.
|
|
343
|
+
- secretsmanager:*Replica*
|
|
344
|
+
- secretsmanager:*TagResource
|
|
345
|
+
- secretsmanager:DeleteSecret
|
|
384
346
|
- secretsmanager:PutSecretValue
|
|
385
|
-
- secretsmanager:RemoveRegionsFromReplication
|
|
386
|
-
- secretsmanager:ReplicateSecretToRegions
|
|
387
347
|
- secretsmanager:RestoreSecret
|
|
388
|
-
- secretsmanager:
|
|
389
|
-
|
|
390
|
-
-
|
|
391
|
-
-
|
|
392
|
-
-
|
|
393
|
-
|
|
394
|
-
|
|
348
|
+
- secretsmanager:Update*
|
|
349
|
+
Resource:
|
|
350
|
+
- !Sub arn:${AWS::Partition}:cloudfront::${AWS::AccountId}:distribution/*
|
|
351
|
+
- !Sub arn:${AWS::Partition}:cognito-identity:*:${AWS::AccountId}:identitypool/*
|
|
352
|
+
- !Sub arn:${AWS::Partition}:cognito-idp:*:${AWS::AccountId}:userpool/*
|
|
353
|
+
- !Sub arn:${AWS::Partition}:secretsmanager:*:${AWS::AccountId}:secret:*
|
|
354
|
+
Condition:
|
|
355
|
+
StringEquals:
|
|
356
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
357
|
+
# managed-by unlocks the deploy role's tag-scoped pool actions, so it can never be added to a pool
|
|
358
|
+
# that does not already carry it (e.g. a customer pool brought in by an import).
|
|
359
|
+
- Effect: Deny
|
|
360
|
+
Action:
|
|
361
|
+
- cognito-idp:TagResource
|
|
362
|
+
Resource: '*'
|
|
363
|
+
Condition:
|
|
364
|
+
ForAnyValue:StringEquals:
|
|
365
|
+
aws:TagKeys:
|
|
366
|
+
- managed-by
|
|
367
|
+
'Null':
|
|
368
|
+
aws:ResourceTag/managed-by: 'true'
|
|
369
|
+
# DynamoDB table lifecycle (provisioning verbs only — no item read/write). Every module table is
|
|
370
|
+
# ${stackName}-<suffix>, under the managed prefix.
|
|
371
|
+
- Effect: Allow
|
|
372
|
+
Action:
|
|
373
|
+
- dynamodb:CreateTable
|
|
374
|
+
- dynamodb:DeleteTable
|
|
375
|
+
- dynamodb:Describe*
|
|
376
|
+
- dynamodb:ListTagsOfResource
|
|
377
|
+
- dynamodb:TagResource
|
|
378
|
+
- dynamodb:UntagResource
|
|
379
|
+
- dynamodb:UpdateContinuousBackups
|
|
380
|
+
- dynamodb:UpdateContributorInsights
|
|
381
|
+
- dynamodb:UpdateTable
|
|
382
|
+
- dynamodb:UpdateTimeToLive
|
|
383
|
+
# The wildcard also covers the tables' indexes (table/<name>/index/<index>).
|
|
384
|
+
Resource: !Sub arn:${AWS::Partition}:dynamodb:*:${AWS::AccountId}:table/${StackNamePrefix}*
|
|
385
|
+
# KMS customer-managed key + alias lifecycle. rbac-service provisions an
|
|
386
|
+
# EventDeliveryKey (AWS::KMS::Key, rotation on) + alias for webhook payload
|
|
387
|
+
# encryption; CreateKey mandates Resource '*', and TagResource on the new key
|
|
388
|
+
# is required or CloudFormation fails with UnauthorizedTaggingOperation. A key carries no name,
|
|
389
|
+
# so the managed-by tag (a stack tag) scopes it: CreateKey and its tags-at-create need the request
|
|
390
|
+
# to carry managed-by; every other key call needs a key that already carries it.
|
|
391
|
+
- Effect: Allow
|
|
392
|
+
Action:
|
|
393
|
+
- kms:CreateKey
|
|
394
|
+
Resource: '*'
|
|
395
|
+
Condition:
|
|
396
|
+
StringEquals:
|
|
397
|
+
aws:RequestTag/managed-by: saaslayer-deployer
|
|
398
|
+
- Effect: Allow
|
|
399
|
+
Action:
|
|
400
|
+
- kms:TagResource
|
|
401
|
+
Resource: !Sub arn:${AWS::Partition}:kms:*:${AWS::AccountId}:key/*
|
|
402
|
+
Condition:
|
|
403
|
+
StringEquals:
|
|
404
|
+
aws:RequestTag/managed-by: saaslayer-deployer
|
|
405
|
+
# Grant + data-plane actions: a resource encrypted with a customer CMK (email-inbound's
|
|
406
|
+
# InboundTable via DynamoDB SSE-KMS) makes the service create a grant AND
|
|
407
|
+
# decrypt/generate data keys against the CMK during provisioning — without these the
|
|
408
|
+
# table create fails AccessDenied (kms:CreateGrant, then kms:Decrypt/GenerateDataKey).
|
|
409
|
+
# Alias verbs authorize against both the alias (next statement) and its key (here).
|
|
410
|
+
- Effect: Allow
|
|
411
|
+
Action:
|
|
412
|
+
- kms:*Alias
|
|
413
|
+
- kms:CreateGrant
|
|
414
|
+
- kms:Decrypt
|
|
415
|
+
- kms:DescribeKey
|
|
416
|
+
- kms:DisableKeyRotation
|
|
417
|
+
- kms:EnableKeyRotation
|
|
418
|
+
- kms:Encrypt
|
|
419
|
+
- kms:GenerateDataKey*
|
|
420
|
+
- kms:Get*
|
|
421
|
+
- kms:List*
|
|
422
|
+
- kms:PutKeyPolicy
|
|
423
|
+
- kms:ReEncrypt*
|
|
424
|
+
- kms:RevokeGrant
|
|
425
|
+
- kms:ScheduleKeyDeletion
|
|
426
|
+
- kms:TagResource
|
|
427
|
+
- kms:UntagResource
|
|
428
|
+
Resource: !Sub arn:${AWS::Partition}:kms:*:${AWS::AccountId}:key/*
|
|
429
|
+
Condition:
|
|
430
|
+
StringEquals:
|
|
431
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
432
|
+
- Effect: Allow
|
|
433
|
+
Action:
|
|
434
|
+
- kms:*Alias
|
|
435
|
+
Resource: !Sub arn:${AWS::Partition}:kms:*:${AWS::AccountId}:alias/${StackNamePrefix}*
|
|
436
|
+
# Lambda function/layer/alias/event-source lifecycle. lambda:InvokeFunction is
|
|
437
|
+
# required because module templates use CloudFormation custom resources
|
|
438
|
+
# (Custom::Delay in user-service) that CloudFormation invokes during deploys. Every module
|
|
439
|
+
# function is ${stackName}-<fn> or (email-inbound's pinned custom-resource functions)
|
|
440
|
+
# sl-email-inbound-<stage>-<fn>, under the managed prefix.
|
|
441
|
+
- Effect: Allow
|
|
442
|
+
Action:
|
|
443
|
+
# Get/List/Delete/Put/Update as globs (inline policy size, as for buckets); the resources below
|
|
444
|
+
# keep them on managed-prefix functions and layers.
|
|
445
|
+
- lambda:AddPermission
|
|
446
|
+
- lambda:CreateFunction
|
|
447
|
+
- lambda:Delete*
|
|
448
|
+
- lambda:Get*
|
|
449
|
+
- lambda:InvokeFunction
|
|
450
|
+
- lambda:List*
|
|
451
|
+
- lambda:PublishLayerVersion
|
|
452
|
+
- lambda:PublishVersion
|
|
453
|
+
- lambda:Put*
|
|
454
|
+
- lambda:RemovePermission
|
|
455
|
+
- lambda:TagResource
|
|
456
|
+
- lambda:UntagResource
|
|
457
|
+
- lambda:Update*
|
|
458
|
+
Resource:
|
|
459
|
+
- !Sub arn:${AWS::Partition}:lambda:*:${AWS::AccountId}:function:${StackNamePrefix}*
|
|
460
|
+
- !Sub arn:${AWS::Partition}:lambda:*:${AWS::AccountId}:layer:${StackNamePrefix}*
|
|
461
|
+
# Event source mappings are addressed by id; lambda:FunctionArn limits them to managed-prefix functions.
|
|
462
|
+
- Effect: Allow
|
|
463
|
+
Action:
|
|
464
|
+
- lambda:DeleteEventSourceMapping
|
|
465
|
+
- lambda:UpdateEventSourceMapping
|
|
466
|
+
Resource: !Sub arn:${AWS::Partition}:lambda:*:${AWS::AccountId}:event-source-mapping:*
|
|
467
|
+
Condition:
|
|
468
|
+
ArnLike:
|
|
469
|
+
lambda:FunctionArn: !Sub arn:${AWS::Partition}:lambda:*:${AWS::AccountId}:function:${StackNamePrefix}*
|
|
470
|
+
# Stack tags reach event source mappings; Lambda's tag calls take no lambda:FunctionArn condition. A
|
|
471
|
+
# mapping's tags grant nothing anywhere in this account.
|
|
472
|
+
- Effect: Allow
|
|
473
|
+
Action:
|
|
474
|
+
- lambda:ListTags
|
|
475
|
+
- lambda:TagResource
|
|
476
|
+
- lambda:UntagResource
|
|
477
|
+
Resource: !Sub arn:${AWS::Partition}:lambda:*:${AWS::AccountId}:event-source-mapping:*
|
|
478
|
+
# S3 bucket lifecycle + bucket configuration for module buckets, plus object
|
|
479
|
+
# read/write used while CloudFormation stages template artifacts. Every module bucket, the shared
|
|
480
|
+
# artifacts bucket and the framework's auto-named deployment bucket start with the managed prefix.
|
|
481
|
+
- Effect: Allow
|
|
482
|
+
Action:
|
|
483
|
+
# Bucket configuration verbs as globs (the role's inline policy is near IAM's 10,240-character
|
|
484
|
+
# limit); the resources below keep them on managed-prefix buckets.
|
|
395
485
|
- s3:CreateBucket
|
|
396
|
-
- s3:DeleteBucket
|
|
397
|
-
- s3:DeleteBucketPolicy
|
|
398
|
-
- s3:DeleteBucketWebsite
|
|
486
|
+
- s3:DeleteBucket*
|
|
399
487
|
- s3:DeleteObject
|
|
400
488
|
- s3:GetAccelerateConfiguration
|
|
401
|
-
- s3:
|
|
402
|
-
- s3:GetBucketCORS
|
|
403
|
-
- s3:GetBucketLocation
|
|
404
|
-
- s3:GetBucketLogging
|
|
405
|
-
- s3:GetBucketNotification
|
|
406
|
-
- s3:GetBucketObjectLockConfiguration
|
|
407
|
-
- s3:GetBucketOwnershipControls
|
|
408
|
-
- s3:GetBucketPolicy
|
|
409
|
-
- s3:GetBucketPublicAccessBlock
|
|
410
|
-
- s3:GetBucketTagging
|
|
411
|
-
- s3:GetBucketVersioning
|
|
412
|
-
- s3:GetBucketWebsite
|
|
489
|
+
- s3:GetBucket*
|
|
413
490
|
- s3:GetEncryptionConfiguration
|
|
414
491
|
- s3:GetLifecycleConfiguration
|
|
415
492
|
- s3:GetObject
|
|
416
493
|
- s3:ListBucket
|
|
417
494
|
- s3:PutAccelerateConfiguration
|
|
418
|
-
- s3:
|
|
419
|
-
- s3:PutBucketCORS
|
|
420
|
-
- s3:PutBucketLogging
|
|
421
|
-
- s3:PutBucketNotification
|
|
422
|
-
- s3:PutBucketObjectLockConfiguration
|
|
423
|
-
- s3:PutBucketOwnershipControls
|
|
424
|
-
- s3:PutBucketPolicy
|
|
425
|
-
- s3:PutBucketPublicAccessBlock
|
|
426
|
-
- s3:PutBucketTagging
|
|
427
|
-
- s3:PutBucketVersioning
|
|
428
|
-
- s3:PutBucketWebsite
|
|
495
|
+
- s3:PutBucket*
|
|
429
496
|
- s3:PutEncryptionConfiguration
|
|
430
497
|
- s3:PutLifecycleConfiguration
|
|
431
498
|
- s3:PutObject
|
|
432
499
|
- s3:PutObjectAcl
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
-
|
|
441
|
-
-
|
|
442
|
-
-
|
|
443
|
-
-
|
|
444
|
-
|
|
445
|
-
-
|
|
446
|
-
-
|
|
447
|
-
-
|
|
448
|
-
-
|
|
449
|
-
|
|
450
|
-
- sqs:TagQueue
|
|
451
|
-
- sqs:UntagQueue
|
|
452
|
-
Resource: '*'
|
|
500
|
+
# The wildcard also covers the buckets' objects (<bucket>/<key>).
|
|
501
|
+
Resource: !Sub arn:${AWS::Partition}:s3:::${StackNamePrefix}*
|
|
502
|
+
# SNS topic lifecycle: module stacks create an ops-alarms topic that
|
|
503
|
+
# alarms publish to (lean health checks). Full lifecycle so
|
|
504
|
+
# CloudFormation can create/read/tag/delete the managed topics (${stackName}-ops-alarms).
|
|
505
|
+
- Effect: Allow
|
|
506
|
+
Action:
|
|
507
|
+
- sns:CreateTopic
|
|
508
|
+
- sns:DeleteTopic
|
|
509
|
+
- sns:GetTopicAttributes
|
|
510
|
+
- sns:SetTopicAttributes
|
|
511
|
+
- sns:Subscribe
|
|
512
|
+
- sns:Unsubscribe
|
|
513
|
+
- sns:ListSubscriptionsByTopic
|
|
514
|
+
- sns:TagResource
|
|
515
|
+
- sns:UntagResource
|
|
516
|
+
Resource: !Sub arn:${AWS::Partition}:sns:*:${AWS::AccountId}:${StackNamePrefix}*
|
|
453
517
|
# Mutating IAM verbs are scoped to the managed-resource prefix (StackNamePrefix) so
|
|
454
518
|
# the exec role can only create/modify SaaSLayer module roles + customer-managed
|
|
455
519
|
# policies — never a pre-existing account role, and never the control-plane primitives
|
|
@@ -486,6 +550,17 @@ Resources:
|
|
|
486
550
|
- iam:TagPolicy
|
|
487
551
|
- iam:UntagPolicy
|
|
488
552
|
Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/${StackNamePrefix}*
|
|
553
|
+
# Cognito email through SES (user-service CognitoEmailSenderArn → DEVELOPER email): on the first such
|
|
554
|
+
# user pool in an account, Cognito creates its email service-linked role with these credentials
|
|
555
|
+
# (UPDATE failed AccessDenied "allow 'email.cognito-idp.amazonaws.com' to call iam:CreateServiceLinkedRole").
|
|
556
|
+
# Scoped to exactly that service and role path.
|
|
557
|
+
- Effect: Allow
|
|
558
|
+
Action:
|
|
559
|
+
- iam:CreateServiceLinkedRole
|
|
560
|
+
Resource: 'arn:aws:iam::*:role/aws-service-role/email.cognito-idp.amazonaws.com/*'
|
|
561
|
+
Condition:
|
|
562
|
+
StringEquals:
|
|
563
|
+
iam:AWSServiceName: email.cognito-idp.amazonaws.com
|
|
489
564
|
# Self-protecting Deny (defense-in-depth): the exec role can never mutate the
|
|
490
565
|
# permissions boundary or the three bootstrap roles, even though prefix scoping
|
|
491
566
|
# already excludes their SaaSLayer* names. An explicit Deny overrides any Allow.
|
|
@@ -504,6 +579,7 @@ Resources:
|
|
|
504
579
|
- iam:UpdateRole
|
|
505
580
|
Resource:
|
|
506
581
|
- !Ref SaaSLayerManagedResourceBoundary
|
|
582
|
+
- !Ref SaaSLayerCloudFormationExecutionPolicy
|
|
507
583
|
- !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/sl-foundation-cfn-exec-role
|
|
508
584
|
- !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/sl-foundation-deploy-role
|
|
509
585
|
- !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/sl-foundation-support-ro-role
|
|
@@ -516,14 +592,22 @@ Resources:
|
|
|
516
592
|
- Effect: Allow
|
|
517
593
|
Action:
|
|
518
594
|
- cloudfront:CreateFunction
|
|
519
|
-
- cloudfront:PublishFunction
|
|
520
|
-
- cloudfront:UpdateFunction
|
|
521
595
|
- cloudfront:DescribeFunction
|
|
522
596
|
- cloudfront:GetFunction
|
|
523
597
|
- cloudfront:ListFunctions
|
|
524
598
|
- cloudfront:ListDistributions
|
|
525
599
|
Resource: '*'
|
|
526
600
|
- !Ref AWS::NoValue
|
|
601
|
+
# Function ARNs carry the function name; every edge function is named under the managed prefix
|
|
602
|
+
# (frontend-hosting ${stackName}-<region code>-f, the native edge's sl-strip-<slug>).
|
|
603
|
+
- Fn::If:
|
|
604
|
+
- TenantEdgeEnabled
|
|
605
|
+
- Effect: Allow
|
|
606
|
+
Action:
|
|
607
|
+
- cloudfront:PublishFunction
|
|
608
|
+
- cloudfront:UpdateFunction
|
|
609
|
+
Resource: !Sub arn:${AWS::Partition}:cloudfront::${AWS::AccountId}:function/${StackNamePrefix}*
|
|
610
|
+
- !Ref AWS::NoValue
|
|
527
611
|
# SES receipt rule set/rule provisioning — only on hosts that run email-inbound
|
|
528
612
|
# (EnableEmailInbound=true). Identity verification (VerifyDomainIdentity/DKIM) runs
|
|
529
613
|
# CP-side in the domain-service, never from the tenant account.
|
|
@@ -543,6 +627,33 @@ Resources:
|
|
|
543
627
|
- ses:DescribeReceiptRule
|
|
544
628
|
Resource: '*'
|
|
545
629
|
- !Ref AWS::NoValue
|
|
630
|
+
# Phone sign-in SMS (user-service phone pools): the AWS::SMSVOICE::ConfigurationSet
|
|
631
|
+
# (${stackName}-phoneSms, under the managed prefix) and its AWS::SMSVOICE::ProtectConfiguration
|
|
632
|
+
# (country rule set; AWS-generated id, so not name-scopable). Lifecycle + tag verbs only: no
|
|
633
|
+
# sending, no account-default protect, spend limit, origination identity or registration changes.
|
|
634
|
+
- Effect: Allow
|
|
635
|
+
Action:
|
|
636
|
+
- sms-voice:AssociateProtectConfiguration
|
|
637
|
+
- sms-voice:CreateConfigurationSet
|
|
638
|
+
- sms-voice:CreateProtectConfiguration
|
|
639
|
+
- sms-voice:DeleteConfigurationSet
|
|
640
|
+
- sms-voice:DeleteProtectConfiguration
|
|
641
|
+
- sms-voice:DisassociateProtectConfiguration
|
|
642
|
+
- sms-voice:GetProtectConfigurationCountryRuleSet
|
|
643
|
+
- sms-voice:ListTagsForResource
|
|
644
|
+
- sms-voice:TagResource
|
|
645
|
+
- sms-voice:UntagResource
|
|
646
|
+
- sms-voice:UpdateProtectConfiguration
|
|
647
|
+
- sms-voice:UpdateProtectConfigurationCountryRuleSet
|
|
648
|
+
Resource:
|
|
649
|
+
- !Sub arn:${AWS::Partition}:sms-voice:*:${AWS::AccountId}:configuration-set/${StackNamePrefix}*
|
|
650
|
+
- !Sub arn:${AWS::Partition}:sms-voice:*:${AWS::AccountId}:protect-configuration/*
|
|
651
|
+
# The SMS resources' read handlers enumerate with Describe*, which take no resource scope.
|
|
652
|
+
- Effect: Allow
|
|
653
|
+
Action:
|
|
654
|
+
- sms-voice:DescribeConfigurationSets
|
|
655
|
+
- sms-voice:DescribeProtectConfigurations
|
|
656
|
+
Resource: '*'
|
|
546
657
|
# Module templates use the AWS::LanguageExtensions transform; CloudFormation
|
|
547
658
|
# requires CreateChangeSet on the transform pseudo-resource to expand it.
|
|
548
659
|
- Effect: Allow
|
|
@@ -550,6 +661,89 @@ Resources:
|
|
|
550
661
|
- cloudformation:CreateChangeSet
|
|
551
662
|
Resource: !Sub arn:${AWS::Partition}:cloudformation:${AWS::Region}:aws:transform/LanguageExtensions
|
|
552
663
|
|
|
664
|
+
# Managed-prefix lifecycle grants of SaaSLayerCloudFormationExecutionRole that do not fit its inline policy (IAM caps a
|
|
665
|
+
# role's inline policies at 10,240 characters in total). Attached to that role only; the role's self-protecting Deny
|
|
666
|
+
# keeps it from changing this policy.
|
|
667
|
+
SaaSLayerCloudFormationExecutionPolicy:
|
|
668
|
+
Type: AWS::IAM::ManagedPolicy
|
|
669
|
+
Properties:
|
|
670
|
+
ManagedPolicyName: sl-foundation-cfn-exec-policy
|
|
671
|
+
Description: Managed-prefix lifecycle of module alarms, event buses and rules, log groups, schedules, parameters and queues.
|
|
672
|
+
PolicyDocument:
|
|
673
|
+
Version: '2012-10-17'
|
|
674
|
+
Statement:
|
|
675
|
+
# Alarm, dashboard, EventBridge bus and rule, log group, schedule, SSM parameter and queue lifecycle. Every
|
|
676
|
+
# module names these from its stack name: alarms ${stackName}-<alarm>, buses ${stackName}-<purpose>, rules
|
|
677
|
+
# ${stackName}-<fn> (unnamed schedule rules get CloudFormation's <stackName>-<LogicalId>-<random>), the schedule
|
|
678
|
+
# group ${stackName}, parameters /${stackName}/..., queues ${stackName}-<purpose>. Log groups are
|
|
679
|
+
# /aws/lambda/<function> (every function is under the managed prefix) and /aws/cognito/${stackName}-logs.
|
|
680
|
+
- Effect: Allow
|
|
681
|
+
Action:
|
|
682
|
+
- cloudwatch:DeleteAlarms
|
|
683
|
+
- cloudwatch:DeleteDashboards
|
|
684
|
+
- cloudwatch:DisableAlarmActions
|
|
685
|
+
- cloudwatch:EnableAlarmActions
|
|
686
|
+
- cloudwatch:PutDashboard
|
|
687
|
+
- cloudwatch:PutMetricAlarm
|
|
688
|
+
- cloudwatch:TagResource
|
|
689
|
+
- cloudwatch:UntagResource
|
|
690
|
+
- events:CreateEventBus
|
|
691
|
+
- events:DeleteEventBus
|
|
692
|
+
- events:DeleteRule
|
|
693
|
+
- events:DisableRule
|
|
694
|
+
- events:EnableRule
|
|
695
|
+
- events:PutRule
|
|
696
|
+
- events:PutTargets
|
|
697
|
+
- events:RemoveTargets
|
|
698
|
+
- events:TagResource
|
|
699
|
+
- events:UntagResource
|
|
700
|
+
- logs:CreateLogGroup
|
|
701
|
+
- logs:CreateLogStream
|
|
702
|
+
- logs:DeleteLogGroup
|
|
703
|
+
- logs:DeleteLogStream
|
|
704
|
+
- logs:DeleteMetricFilter
|
|
705
|
+
- logs:DeleteRetentionPolicy
|
|
706
|
+
- logs:PutDestination
|
|
707
|
+
- logs:PutDestinationPolicy
|
|
708
|
+
- logs:PutLogEvents
|
|
709
|
+
- logs:PutMetricFilter
|
|
710
|
+
- logs:PutRetentionPolicy
|
|
711
|
+
- logs:TagLogGroup
|
|
712
|
+
- logs:TagResource
|
|
713
|
+
- logs:UntagLogGroup
|
|
714
|
+
- logs:UntagResource
|
|
715
|
+
- scheduler:CreateSchedule
|
|
716
|
+
- scheduler:CreateScheduleGroup
|
|
717
|
+
- scheduler:DeleteSchedule
|
|
718
|
+
- scheduler:DeleteScheduleGroup
|
|
719
|
+
- scheduler:TagResource
|
|
720
|
+
- scheduler:UntagResource
|
|
721
|
+
- scheduler:UpdateSchedule
|
|
722
|
+
- ssm:AddTagsToResource
|
|
723
|
+
- ssm:DeleteParameter
|
|
724
|
+
- ssm:DeleteParameters
|
|
725
|
+
- ssm:PutParameter
|
|
726
|
+
- ssm:RemoveTagsFromResource
|
|
727
|
+
- sqs:CreateQueue
|
|
728
|
+
- sqs:DeleteQueue
|
|
729
|
+
- sqs:SetQueueAttributes
|
|
730
|
+
- sqs:TagQueue
|
|
731
|
+
- sqs:UntagQueue
|
|
732
|
+
# Each action matches only its own service's ARNs, so one statement carries every service.
|
|
733
|
+
Resource:
|
|
734
|
+
- !Sub arn:${AWS::Partition}:cloudwatch:*:${AWS::AccountId}:alarm:${StackNamePrefix}*
|
|
735
|
+
- !Sub arn:${AWS::Partition}:cloudwatch::${AWS::AccountId}:dashboard/${StackNamePrefix}*
|
|
736
|
+
- !Sub arn:${AWS::Partition}:events:*:${AWS::AccountId}:event-bus/${StackNamePrefix}*
|
|
737
|
+
- !Sub arn:${AWS::Partition}:events:*:${AWS::AccountId}:event-busv2/${StackNamePrefix}*
|
|
738
|
+
- !Sub arn:${AWS::Partition}:events:*:${AWS::AccountId}:rule/${StackNamePrefix}*
|
|
739
|
+
- !Sub arn:${AWS::Partition}:logs:*:${AWS::AccountId}:log-group:/aws/lambda/${StackNamePrefix}*
|
|
740
|
+
- !Sub arn:${AWS::Partition}:logs:*:${AWS::AccountId}:log-group:/aws/cognito/${StackNamePrefix}*
|
|
741
|
+
- !Sub arn:${AWS::Partition}:logs:*:${AWS::AccountId}:destination:${StackNamePrefix}*
|
|
742
|
+
- !Sub arn:${AWS::Partition}:scheduler:*:${AWS::AccountId}:schedule-group/${StackNamePrefix}*
|
|
743
|
+
- !Sub arn:${AWS::Partition}:scheduler:*:${AWS::AccountId}:schedule/${StackNamePrefix}*
|
|
744
|
+
- !Sub arn:${AWS::Partition}:ssm:*:${AWS::AccountId}:parameter/${StackNamePrefix}*
|
|
745
|
+
- !Sub arn:${AWS::Partition}:sqs:*:${AWS::AccountId}:${StackNamePrefix}*
|
|
746
|
+
|
|
553
747
|
# Permissions boundary attached to every IAM role created by SaaSLayer module templates (the
|
|
554
748
|
# deployer passes this policy's ARN into each module deploy). A module role's effective runtime
|
|
555
749
|
# permissions are the INTERSECTION of its own policy and this boundary, so even a template bug
|
|
@@ -595,6 +789,8 @@ Resources:
|
|
|
595
789
|
- cognito-idp:UpdateIdentityProvider
|
|
596
790
|
- dynamodb:BatchGetItem
|
|
597
791
|
- dynamodb:BatchWriteItem
|
|
792
|
+
# TransactWriteItems ConditionCheck items (permissions-service audit writes check erasure markers).
|
|
793
|
+
- dynamodb:ConditionCheckItem
|
|
598
794
|
- dynamodb:DeleteItem
|
|
599
795
|
- dynamodb:DescribeStream
|
|
600
796
|
- dynamodb:DescribeTable
|
|
@@ -672,6 +868,13 @@ Resources:
|
|
|
672
868
|
- ses:SendEmail
|
|
673
869
|
Resource:
|
|
674
870
|
- !Sub arn:${AWS::Partition}:ses:*:${AWS::AccountId}:identity/*
|
|
871
|
+
# Phone sign-in SMS: Cognito sends through a user-service phone pool's SMS caller role. Send only; the
|
|
872
|
+
# role's own policy scopes it to its configuration set and origination identity.
|
|
873
|
+
- Effect: Allow
|
|
874
|
+
Action:
|
|
875
|
+
- sms-voice:SendTextMessage
|
|
876
|
+
Resource:
|
|
877
|
+
- !Sub arn:${AWS::Partition}:sms-voice:*:${AWS::AccountId}:*
|
|
675
878
|
# SES runtime (forward/notify sends + the active-rule-set custom resource) — only on hosts
|
|
676
879
|
# that run email-inbound. Receiving into S3 is granted to the ses.amazonaws.com service
|
|
677
880
|
# principal by the module's bucket policy, not here.
|
|
@@ -687,8 +890,9 @@ Resources:
|
|
|
687
890
|
Resource: '*'
|
|
688
891
|
- !Ref AWS::NoValue
|
|
689
892
|
|
|
690
|
-
# Cross-account WRITE entry point for the SaaSLayer control
|
|
691
|
-
#
|
|
893
|
+
# Cross-account WRITE entry point for the managing SaaSLayer control planes. Trust is rendered from
|
|
894
|
+
# TrustEntries: per control plane, only its account, only its deploy identity role (aws:PrincipalArn) and
|
|
895
|
+
# only with its trust identifier (sts:ExternalId). Every mutating grant is scoped
|
|
692
896
|
# to the SaaSLayer stack namespace (StackNamePrefix) or the deployment artifact buckets; resource
|
|
693
897
|
# creation itself always happens through CloudFormation with the execution role above.
|
|
694
898
|
SaaSLayerDeploymentRole:
|
|
@@ -697,14 +901,7 @@ Resources:
|
|
|
697
901
|
RoleName: sl-foundation-deploy-role
|
|
698
902
|
AssumeRolePolicyDocument:
|
|
699
903
|
Version: '2012-10-17'
|
|
700
|
-
Statement:
|
|
701
|
-
- Effect: Allow
|
|
702
|
-
Principal:
|
|
703
|
-
AWS: !Sub arn:aws:iam::${ControlPlaneAccountId}:root
|
|
704
|
-
Action: sts:AssumeRole
|
|
705
|
-
Condition:
|
|
706
|
-
StringEquals:
|
|
707
|
-
sts:ExternalId: !Ref ExternalId
|
|
904
|
+
Statement: []
|
|
708
905
|
Policies:
|
|
709
906
|
- PolicyName: saaslayer-stack-lifecycle
|
|
710
907
|
PolicyDocument:
|
|
@@ -731,6 +928,36 @@ Resources:
|
|
|
731
928
|
- cloudformation:DetectStackDrift
|
|
732
929
|
- cloudformation:DetectStackResourceDrift
|
|
733
930
|
Resource: !Sub arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackNamePrefix}*
|
|
931
|
+
# Resource import (foundation 8.0.0): only the retained-resource adoption path imports
|
|
932
|
+
# (src/retained-adoption.ts, change set saaslayer-adopt-<runId>), and only the resource types it
|
|
933
|
+
# adopts. CloudFormation has no change-set-type condition key; cloudformation:ImportResourceTypes is
|
|
934
|
+
# present exactly when a change set imports.
|
|
935
|
+
- Sid: DenyImportsOutsideAdoption
|
|
936
|
+
Effect: Deny
|
|
937
|
+
Action:
|
|
938
|
+
- cloudformation:CreateChangeSet
|
|
939
|
+
Resource: '*'
|
|
940
|
+
Condition:
|
|
941
|
+
'Null':
|
|
942
|
+
cloudformation:ImportResourceTypes: 'false'
|
|
943
|
+
StringNotLike:
|
|
944
|
+
cloudformation:ChangeSetName: saaslayer-adopt-*
|
|
945
|
+
- Sid: DenyImportOfUnadoptableTypes
|
|
946
|
+
Effect: Deny
|
|
947
|
+
Action:
|
|
948
|
+
- cloudformation:CreateChangeSet
|
|
949
|
+
Resource: '*'
|
|
950
|
+
Condition:
|
|
951
|
+
ForAnyValue:StringNotEquals:
|
|
952
|
+
cloudformation:ImportResourceTypes:
|
|
953
|
+
- AWS::DynamoDB::Table
|
|
954
|
+
- AWS::Cognito::UserPool
|
|
955
|
+
- AWS::Cognito::UserPoolClient
|
|
956
|
+
- AWS::Cognito::UserPoolGroup
|
|
957
|
+
- AWS::Cognito::IdentityPool
|
|
958
|
+
- AWS::S3::Bucket
|
|
959
|
+
- AWS::KMS::Key
|
|
960
|
+
- AWS::SecretsManager::Secret
|
|
734
961
|
# Actions the API cannot scope to a stack ARN: ValidateTemplate, and the
|
|
735
962
|
# drift-detection status poll which operates on a detection id, not a stack.
|
|
736
963
|
- Effect: Allow
|
|
@@ -738,6 +965,14 @@ Resources:
|
|
|
738
965
|
- cloudformation:ValidateTemplate
|
|
739
966
|
- cloudformation:DescribeStackDriftDetectionStatus
|
|
740
967
|
Resource: '*'
|
|
968
|
+
# Connection authorization metadata (ADR 0005 §4): the control plane reads who may authorize
|
|
969
|
+
# SaaSLayer connections to this account through this role. Exactly one parameter, in this
|
|
970
|
+
# stack's (home) region; it holds role ARNs and control-plane ids, no secret.
|
|
971
|
+
- Sid: ReadConnectionAuthorizers
|
|
972
|
+
Effect: Allow
|
|
973
|
+
Action:
|
|
974
|
+
- ssm:GetParameter
|
|
975
|
+
Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/saaslayer/foundation/connection-authorizers
|
|
741
976
|
# The single permitted pass-role path: this role may hand CloudFormation exactly one
|
|
742
977
|
# execution role. It cannot pass any other role in the account.
|
|
743
978
|
- Effect: Allow
|
|
@@ -769,17 +1004,12 @@ Resources:
|
|
|
769
1004
|
- !Sub arn:aws:s3:::${StackNamePrefix}*
|
|
770
1005
|
- !Sub arn:aws:s3:::${StackNamePrefix}*/*
|
|
771
1006
|
# Deploy tooling introspection after stack operations complete: stack enumeration
|
|
772
|
-
# (ListStacks has no resource scoping)
|
|
773
|
-
# tooling
|
|
1007
|
+
# (ListStacks has no resource scoping) and lambda version/alias inspection. The API Gateway
|
|
1008
|
+
# calls the Serverless tooling and the domain-service make outside CloudFormation are below.
|
|
774
1009
|
- Effect: Allow
|
|
775
1010
|
Action:
|
|
776
1011
|
- cloudformation:ListStacks
|
|
777
1012
|
- cloudformation:ListStackResources
|
|
778
|
-
- apigateway:DELETE
|
|
779
|
-
- apigateway:GET
|
|
780
|
-
- apigateway:PATCH
|
|
781
|
-
- apigateway:POST
|
|
782
|
-
- apigateway:PUT
|
|
783
1013
|
- lambda:GetAlias
|
|
784
1014
|
- lambda:GetFunction
|
|
785
1015
|
- lambda:GetFunctionConfiguration
|
|
@@ -787,6 +1017,56 @@ Resources:
|
|
|
787
1017
|
- lambda:ListTags
|
|
788
1018
|
- lambda:ListVersionsByFunction
|
|
789
1019
|
Resource: '*'
|
|
1020
|
+
# API Gateway outside CloudFormation (foundation 8.0.0). Reads stay open: osls finds the module's REST
|
|
1021
|
+
# API by name in GET /restapis, and the domain-service probes GET /apis/<id> and lists /domainnames.
|
|
1022
|
+
- Sid: ApiGatewayReads
|
|
1023
|
+
Effect: Allow
|
|
1024
|
+
Action:
|
|
1025
|
+
- apigateway:GET
|
|
1026
|
+
Resource: !Sub arn:${AWS::Partition}:apigateway:*::/*
|
|
1027
|
+
# The domain-service creates a custom domain (v1 or v2) only carrying managed-by=saaslayer-deployer.
|
|
1028
|
+
- Sid: CreateManagedDomains
|
|
1029
|
+
Effect: Allow
|
|
1030
|
+
Action:
|
|
1031
|
+
- apigateway:POST
|
|
1032
|
+
Resource: !Sub arn:${AWS::Partition}:apigateway:*::/domainnames
|
|
1033
|
+
Condition:
|
|
1034
|
+
StringEquals:
|
|
1035
|
+
aws:RequestTag/managed-by: saaslayer-deployer
|
|
1036
|
+
# Base path / API mappings and deletes reach only domains carrying managed-by: a customer's own
|
|
1037
|
+
# domain of the same name (a swallowed create Conflict) or a vanity host the deployer did not create
|
|
1038
|
+
# is refused. Mappings take the tags of their domain for authorization.
|
|
1039
|
+
- Sid: ManagedDomainChanges
|
|
1040
|
+
Effect: Allow
|
|
1041
|
+
Action:
|
|
1042
|
+
- apigateway:DELETE
|
|
1043
|
+
- apigateway:PATCH
|
|
1044
|
+
- apigateway:POST
|
|
1045
|
+
Resource: !Sub arn:${AWS::Partition}:apigateway:*::/domainnames/*
|
|
1046
|
+
Condition:
|
|
1047
|
+
StringEquals:
|
|
1048
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1049
|
+
# osls's post-deploy stage update (REST modules with tags): create/update the stage of a REST API that
|
|
1050
|
+
# carries managed-by (stack tags reach the RestApi; a stage takes its API's tags for authorization).
|
|
1051
|
+
- Sid: ManagedRestApiStages
|
|
1052
|
+
Effect: Allow
|
|
1053
|
+
Action:
|
|
1054
|
+
- apigateway:PATCH
|
|
1055
|
+
- apigateway:POST
|
|
1056
|
+
Resource:
|
|
1057
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/restapis/*/stages
|
|
1058
|
+
- !Sub arn:${AWS::Partition}:apigateway:*::/restapis/*/stages/*
|
|
1059
|
+
Condition:
|
|
1060
|
+
StringEquals:
|
|
1061
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1062
|
+
# ...and set the stage's tags. The /tags resource takes no resource-tag condition; API Gateway also
|
|
1063
|
+
# requires PATCH on the tagged resource itself, which ManagedRestApiStages grants only on managed stages.
|
|
1064
|
+
- Sid: ApiGatewayStageTags
|
|
1065
|
+
Effect: Allow
|
|
1066
|
+
Action:
|
|
1067
|
+
- apigateway:DELETE
|
|
1068
|
+
- apigateway:PUT
|
|
1069
|
+
Resource: !Sub arn:${AWS::Partition}:apigateway:*::/tags/*
|
|
790
1070
|
# Env-mode credential hot-swap: revoke/rotate updates a managed function's environment directly
|
|
791
1071
|
# (UpdateFunctionConfiguration with RevisionId, read back with GetFunctionConfiguration above) instead
|
|
792
1072
|
# of a stack deploy. Managed-prefix functions only.
|
|
@@ -810,8 +1090,9 @@ Resources:
|
|
|
810
1090
|
- cognito-idp:AdminUpdateUserAttributes
|
|
811
1091
|
- cognito-idp:ListUsers
|
|
812
1092
|
# Scoped to SaaSLayer-managed pools by tag — the seed can never touch the customer's
|
|
813
|
-
# own Cognito pools.
|
|
814
|
-
#
|
|
1093
|
+
# own Cognito pools. user-service creates the pool with managed-by:saaslayer-deployer in its
|
|
1094
|
+
# explicit UserPoolTags (stack tags do not reach user pools), so it is tagged before the
|
|
1095
|
+
# post-deploy seed runs, and the execution role cannot add managed-by to any other pool.
|
|
815
1096
|
Resource: !Sub arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/*
|
|
816
1097
|
Condition:
|
|
817
1098
|
StringEquals:
|
|
@@ -849,6 +1130,105 @@ Resources:
|
|
|
849
1130
|
- logs:DeleteLogGroup
|
|
850
1131
|
Resource:
|
|
851
1132
|
- !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${StackNamePrefix}*
|
|
1133
|
+
# Recovery inventory (ADR 0006 §2.2, foundation 6.5.0): before a destroy removes anything, the deployer
|
|
1134
|
+
# describes every stateful resource of the module stacks to write the deployment's recovery record.
|
|
1135
|
+
# Metadata reads only — never a secret or parameter value. Tables, buckets and secrets are managed-prefix
|
|
1136
|
+
# scoped; a module's KMS key is addressed by an id the prefix does not cover, so it is scoped to the account.
|
|
1137
|
+
- Sid: RecoveryInventoryScopedReads
|
|
1138
|
+
Effect: Allow
|
|
1139
|
+
Action:
|
|
1140
|
+
- dynamodb:DescribeTable
|
|
1141
|
+
- dynamodb:DescribeContinuousBackups
|
|
1142
|
+
- s3:GetBucketVersioning
|
|
1143
|
+
- secretsmanager:DescribeSecret
|
|
1144
|
+
- kms:DescribeKey
|
|
1145
|
+
Resource:
|
|
1146
|
+
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${StackNamePrefix}*
|
|
1147
|
+
- !Sub arn:aws:s3:::${StackNamePrefix}*
|
|
1148
|
+
- !Sub arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${StackNamePrefix}*
|
|
1149
|
+
- !Sub arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/*
|
|
1150
|
+
# Pool and app-client reads, limited to SaaSLayer-managed pools by tag like the seed's admin actions.
|
|
1151
|
+
- Sid: RecoveryInventoryPoolReads
|
|
1152
|
+
Effect: Allow
|
|
1153
|
+
Action:
|
|
1154
|
+
- cognito-idp:DescribeUserPool
|
|
1155
|
+
- cognito-idp:DescribeUserPoolClient
|
|
1156
|
+
Resource: !Sub arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/*
|
|
1157
|
+
Condition:
|
|
1158
|
+
StringEquals:
|
|
1159
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1160
|
+
# Identity pool reads (foundation 7.2.0): this account and region only, metadata (name) only. No tag condition,
|
|
1161
|
+
# so a retain never refuses on an identity pool its stack tags did not reach; the purge delete stays tag-limited.
|
|
1162
|
+
- Sid: RecoveryInventoryIdentityPoolReads
|
|
1163
|
+
Effect: Allow
|
|
1164
|
+
Action:
|
|
1165
|
+
- cognito-identity:DescribeIdentityPool
|
|
1166
|
+
Resource: !Sub arn:aws:cognito-identity:${AWS::Region}:${AWS::AccountId}:identitypool/*
|
|
1167
|
+
# DescribeUserPoolDomain and DescribeParameters support no resource-level scoping.
|
|
1168
|
+
- Sid: RecoveryInventoryUnscopedReads
|
|
1169
|
+
Effect: Allow
|
|
1170
|
+
Action:
|
|
1171
|
+
- cognito-idp:DescribeUserPoolDomain
|
|
1172
|
+
- ssm:DescribeParameters
|
|
1173
|
+
Resource: '*'
|
|
1174
|
+
# Purge (ADR 0006 §2.1, foundation 7.1.0): a delete destroy, or the purge of a retired deployment, deletes
|
|
1175
|
+
# what the deployment kept in custody, item by item from its recorded inventory: the backups of its tables,
|
|
1176
|
+
# its own buckets (emptied with the object grants above), its Secrets Manager secrets with no recovery
|
|
1177
|
+
# window, and its user pools (domain first, deletion protection off), app clients, identity pools (7.2.0) and
|
|
1178
|
+
# KMS keys. Tables, buckets and secrets are managed-prefix scoped; pools and keys are limited to
|
|
1179
|
+
# SaaSLayer-managed ones by tag.
|
|
1180
|
+
- Sid: PurgeScopedDeletes
|
|
1181
|
+
Effect: Allow
|
|
1182
|
+
Action:
|
|
1183
|
+
- dynamodb:DeleteBackup
|
|
1184
|
+
- s3:DeleteBucket
|
|
1185
|
+
- secretsmanager:DeleteSecret
|
|
1186
|
+
Resource:
|
|
1187
|
+
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${StackNamePrefix}*/backup/*
|
|
1188
|
+
- !Sub arn:aws:s3:::${StackNamePrefix}*
|
|
1189
|
+
- !Sub arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${StackNamePrefix}*
|
|
1190
|
+
- Sid: PurgeManagedPoolsAndKeys
|
|
1191
|
+
Effect: Allow
|
|
1192
|
+
Action:
|
|
1193
|
+
- cognito-idp:DeleteUserPool
|
|
1194
|
+
- cognito-idp:DeleteUserPoolClient
|
|
1195
|
+
- cognito-idp:DeleteUserPoolDomain
|
|
1196
|
+
- cognito-idp:UpdateUserPool
|
|
1197
|
+
- cognito-identity:DeleteIdentityPool
|
|
1198
|
+
- kms:ScheduleKeyDeletion
|
|
1199
|
+
Resource:
|
|
1200
|
+
- !Sub arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/*
|
|
1201
|
+
- !Sub arn:aws:cognito-identity:${AWS::Region}:${AWS::AccountId}:identitypool/*
|
|
1202
|
+
- !Sub arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/*
|
|
1203
|
+
Condition:
|
|
1204
|
+
StringEquals:
|
|
1205
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1206
|
+
# Adopt (ADR 0006 §2.2 step 5, foundation 7.2.0): once a retained user pool is imported back, every user is
|
|
1207
|
+
# signed out (AdminUserGlobalSignOut, listed with ListUsers) so refresh tokens issued before the retain stop
|
|
1208
|
+
# working. Limited to SaaSLayer-managed pools by tag; no user data is read or written beyond usernames.
|
|
1209
|
+
- Sid: AdoptSessionRevocation
|
|
1210
|
+
Effect: Allow
|
|
1211
|
+
Action:
|
|
1212
|
+
- cognito-idp:ListUsers
|
|
1213
|
+
- cognito-idp:AdminUserGlobalSignOut
|
|
1214
|
+
Resource: !Sub arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/*
|
|
1215
|
+
Condition:
|
|
1216
|
+
StringEquals:
|
|
1217
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1218
|
+
# ListBackups supports no resource-level scoping; the purge lists only its own tables' backups by name.
|
|
1219
|
+
- Sid: PurgeBackupListing
|
|
1220
|
+
Effect: Allow
|
|
1221
|
+
Action:
|
|
1222
|
+
- dynamodb:ListBackups
|
|
1223
|
+
Resource: '*'
|
|
1224
|
+
# Login-domain quota (foundation 7.4.0): Cognito allows 4 custom domains per account and region, so before
|
|
1225
|
+
# a deployment gets a branded login host the deployer counts the account's user pools in the region.
|
|
1226
|
+
# Read-only (pool ids and names); ListUserPools supports no resource-level scoping.
|
|
1227
|
+
- Sid: LoginDomainQuotaRead
|
|
1228
|
+
Effect: Allow
|
|
1229
|
+
Action:
|
|
1230
|
+
- cognito-idp:ListUserPools
|
|
1231
|
+
Resource: '*'
|
|
852
1232
|
# Data migrations (@saaslayer/migrations): hop into a service stack's own migrate role; the
|
|
853
1233
|
# role's own policy limits it to that service's tables. Its trust is account root + an
|
|
854
1234
|
# aws:PrincipalArn condition, which delegates to this identity policy, so the grant is required.
|
|
@@ -857,8 +1237,8 @@ Resources:
|
|
|
857
1237
|
Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${StackNamePrefix}*-migrate
|
|
858
1238
|
# Domain-mapping (D1.0, monorepo-88mn.3): the domain-service assumes this role to issue an ACM
|
|
859
1239
|
# cert for the tenant's {slug}.saaslayer-cloud.com names, then attach an API-GW regional custom
|
|
860
|
-
# domain — the apigateway create/
|
|
861
|
-
#
|
|
1240
|
+
# domain — the apigateway create/map/delete verbs are granted above (CreateManagedDomains,
|
|
1241
|
+
# ManagedDomainChanges), so only ACM is added here. Scoped to certs tagged managed-by=saaslayer-deployer so this
|
|
862
1242
|
# role can only touch certs it created; RequestCertificate has no resource-level ARN, so the
|
|
863
1243
|
# request-tag condition is the only guard. Regional custom domains do NOT need a service-linked
|
|
864
1244
|
# role; add iam:CreateServiceLinkedRole for apigateway ONLY if domain-iam-spike.sh (D1.0a) proves it.
|
|
@@ -904,6 +1284,9 @@ Resources:
|
|
|
904
1284
|
- Effect: Allow
|
|
905
1285
|
Action:
|
|
906
1286
|
- ssm:GetParameter
|
|
1287
|
+
# User-service's first-admin seed reads the endpoint and scoped service key in
|
|
1288
|
+
# one GetParameters call. Keep that batch read in the same deployment namespace.
|
|
1289
|
+
- ssm:GetParameters
|
|
907
1290
|
- ssm:PutParameter
|
|
908
1291
|
# DeleteParameter: the destroy/teardown phase clears the handoff params (they are written
|
|
909
1292
|
# by PutParameter, NOT CloudFormation, so a stack delete leaves them behind) — M4b.
|
|
@@ -929,28 +1312,54 @@ Resources:
|
|
|
929
1312
|
- TenantEdgeEnabled
|
|
930
1313
|
- Effect: Allow
|
|
931
1314
|
Action:
|
|
932
|
-
- cloudfront:CreateDistribution
|
|
933
1315
|
- cloudfront:GetDistribution
|
|
934
1316
|
- cloudfront:GetDistributionConfig
|
|
935
|
-
- cloudfront:UpdateDistribution
|
|
936
1317
|
- cloudfront:ListDistributions
|
|
937
|
-
- cloudfront:TagResource
|
|
938
1318
|
- cloudfront:CreateFunction
|
|
939
|
-
- cloudfront:PublishFunction
|
|
940
|
-
- cloudfront:UpdateFunction
|
|
941
1319
|
- cloudfront:DescribeFunction
|
|
942
1320
|
- cloudfront:GetFunction
|
|
943
1321
|
- cloudfront:ListFunctions
|
|
944
|
-
|
|
945
|
-
|
|
1322
|
+
Resource: '*'
|
|
1323
|
+
- !Ref AWS::NoValue
|
|
1324
|
+
# The distro is created and tagged only with the request carrying managed-by (CreateDistributionWithTags;
|
|
1325
|
+
# provision and teardown tag the distro they find by its {slug} alias before changing it), and updated (the
|
|
1326
|
+
# teardown's disable) and deleted (native/B teardown) only while it carries managed-by.
|
|
1327
|
+
- Fn::If:
|
|
1328
|
+
- TenantEdgeEnabled
|
|
1329
|
+
- Effect: Allow
|
|
1330
|
+
Action:
|
|
1331
|
+
- cloudfront:CreateDistribution
|
|
1332
|
+
- cloudfront:TagResource
|
|
1333
|
+
Resource: '*'
|
|
1334
|
+
Condition:
|
|
1335
|
+
StringEquals:
|
|
1336
|
+
aws:RequestTag/managed-by: saaslayer-deployer
|
|
1337
|
+
- !Ref AWS::NoValue
|
|
1338
|
+
- Fn::If:
|
|
1339
|
+
- TenantEdgeEnabled
|
|
1340
|
+
- Effect: Allow
|
|
1341
|
+
Action:
|
|
946
1342
|
- cloudfront:DeleteDistribution
|
|
1343
|
+
- cloudfront:UpdateDistribution
|
|
1344
|
+
Resource: !Sub arn:${AWS::Partition}:cloudfront::${AWS::AccountId}:distribution/*
|
|
1345
|
+
Condition:
|
|
1346
|
+
StringEquals:
|
|
1347
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
1348
|
+
- !Ref AWS::NoValue
|
|
1349
|
+
# The strip Function is sl-strip-<slug>, under the managed prefix; its ARN carries the name.
|
|
1350
|
+
- Fn::If:
|
|
1351
|
+
- TenantEdgeEnabled
|
|
1352
|
+
- Effect: Allow
|
|
1353
|
+
Action:
|
|
1354
|
+
- cloudfront:PublishFunction
|
|
1355
|
+
- cloudfront:UpdateFunction
|
|
947
1356
|
- cloudfront:DeleteFunction
|
|
948
|
-
Resource:
|
|
1357
|
+
Resource: !Sub arn:${AWS::Partition}:cloudfront::${AWS::AccountId}:function/${StackNamePrefix}*
|
|
949
1358
|
- !Ref AWS::NoValue
|
|
950
1359
|
|
|
951
1360
|
# Cross-account READ-ONLY role for SaaSLayer support staff to diagnose managed deployments
|
|
952
|
-
# without the deployment role's write power. Trust
|
|
953
|
-
# account
|
|
1361
|
+
# without the deployment role's write power. Trust is rendered like the deployment role's (per
|
|
1362
|
+
# control plane: its account, its support identity role and its trust identifier) and additionally pins the session name to saaslayer-support-* so each
|
|
954
1363
|
# assumption is attributable in CloudTrail. Grants carry only Get/List/Describe verbs — enforced
|
|
955
1364
|
# by tests/bootstrap.test.js — and exclude all data-plane reads: no S3 object reads, no DynamoDB
|
|
956
1365
|
# item reads, no SSM parameter values, no Secrets Manager secret values, no function code downloads.
|
|
@@ -964,16 +1373,7 @@ Resources:
|
|
|
964
1373
|
RoleName: sl-foundation-support-ro-role
|
|
965
1374
|
AssumeRolePolicyDocument:
|
|
966
1375
|
Version: '2012-10-17'
|
|
967
|
-
Statement:
|
|
968
|
-
- Effect: Allow
|
|
969
|
-
Principal:
|
|
970
|
-
AWS: !Sub arn:aws:iam::${ControlPlaneAccountId}:root
|
|
971
|
-
Action: sts:AssumeRole
|
|
972
|
-
Condition:
|
|
973
|
-
StringEquals:
|
|
974
|
-
sts:ExternalId: !Ref ExternalId
|
|
975
|
-
StringLike:
|
|
976
|
-
sts:RoleSessionName: saaslayer-support-*
|
|
1376
|
+
Statement: []
|
|
977
1377
|
Policies:
|
|
978
1378
|
- PolicyName: saaslayer-support-read-only
|
|
979
1379
|
PolicyDocument:
|
|
@@ -997,6 +1397,12 @@ Resources:
|
|
|
997
1397
|
Action:
|
|
998
1398
|
- cloudformation:ListStacks
|
|
999
1399
|
Resource: '*'
|
|
1400
|
+
# Foundation home: the foundation roles' aws:cloudformation:stack-id tag names this account
|
|
1401
|
+
# stack and so its home region, which foundation discovery reads before DescribeStacks.
|
|
1402
|
+
- Effect: Allow
|
|
1403
|
+
Action:
|
|
1404
|
+
- iam:ListRoleTags
|
|
1405
|
+
Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/sl-foundation-*
|
|
1000
1406
|
# Configuration reads scoped by resource tag: these services support the
|
|
1001
1407
|
# aws:ResourceTag condition key, and every SaaSLayer-deployed resource carries
|
|
1002
1408
|
# managed-by=saaslayer-deployer via stack tags. Untagged (customer) resources
|
|
@@ -1043,6 +1449,34 @@ Resources:
|
|
|
1043
1449
|
- logs:GetLogGroupFields
|
|
1044
1450
|
- logs:GetLogRecord
|
|
1045
1451
|
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${StackNamePrefix}*:*
|
|
1452
|
+
# Phone sign-in SMS readiness (read-only): account tier + spend limit, origination identities and
|
|
1453
|
+
# their registrations, a sandbox account's verified destination numbers, and the read-back of a phone
|
|
1454
|
+
# pool's configuration set + protect country rules. Account-level facts that carry no deployer tag,
|
|
1455
|
+
# so not tag-scoped.
|
|
1456
|
+
- Effect: Allow
|
|
1457
|
+
Action:
|
|
1458
|
+
- sms-voice:DescribeAccountAttributes
|
|
1459
|
+
- sms-voice:DescribeConfigurationSets
|
|
1460
|
+
- sms-voice:DescribePhoneNumbers
|
|
1461
|
+
- sms-voice:DescribePools
|
|
1462
|
+
- sms-voice:DescribeProtectConfigurations
|
|
1463
|
+
- sms-voice:DescribeRegistrations
|
|
1464
|
+
- sms-voice:DescribeSenderIds
|
|
1465
|
+
- sms-voice:DescribeSpendLimits
|
|
1466
|
+
- sms-voice:DescribeVerifiedDestinationNumbers
|
|
1467
|
+
- sms-voice:GetProtectConfigurationCountryRuleSet
|
|
1468
|
+
Resource: '*'
|
|
1469
|
+
# Recovery email readiness (read-only), checked before a recovery cutover: the account's SES sending status
|
|
1470
|
+
# (production access, sending enabled) and whether a sender identity is verified for sending. Account-level
|
|
1471
|
+
# facts that carry no deployer tag, so not tag-scoped; identity reads stay within this account.
|
|
1472
|
+
- Effect: Allow
|
|
1473
|
+
Action:
|
|
1474
|
+
- ses:GetAccount
|
|
1475
|
+
Resource: '*'
|
|
1476
|
+
- Effect: Allow
|
|
1477
|
+
Action:
|
|
1478
|
+
- ses:GetEmailIdentity
|
|
1479
|
+
Resource: !Sub arn:${AWS::Partition}:ses:*:${AWS::AccountId}:identity/*
|
|
1046
1480
|
# Alarm/dashboard state for module observability. CloudWatch alarms support
|
|
1047
1481
|
# aws:ResourceTag; DescribeAlarms is an enumeration API evaluated per-alarm.
|
|
1048
1482
|
- Effect: Allow
|
|
@@ -1068,12 +1502,29 @@ Resources:
|
|
|
1068
1502
|
kms:ViaService: ssm.*.amazonaws.com
|
|
1069
1503
|
kms:EncryptionContext:PARAMETER_ARN: !Sub arn:${AWS::Partition}:ssm:*:${AWS::AccountId}:parameter/saaslayer/deployment/*
|
|
1070
1504
|
|
|
1505
|
+
# Connection authorization metadata (ADR 0005 §4), in this stack's (home) region: who may authorize
|
|
1506
|
+
# SaaSLayer org connections (ConnectionAuthorizerArns) and which control planes hold trust entries.
|
|
1507
|
+
# The controlPlanes literal (the line after "controlPlanes") is rendered from TrustEntries by the CLI.
|
|
1508
|
+
SaaSLayerConnectionAuthorizers:
|
|
1509
|
+
Type: AWS::SSM::Parameter
|
|
1510
|
+
Properties:
|
|
1511
|
+
Name: /saaslayer/foundation/connection-authorizers
|
|
1512
|
+
Type: String
|
|
1513
|
+
Description: SaaSLayer connection authorizers and managing control planes of this account (no secret).
|
|
1514
|
+
Value: !Join
|
|
1515
|
+
- ''
|
|
1516
|
+
- - '{"v":1,"connectionAuthorizerArns":["'
|
|
1517
|
+
- !Join ['","', !Ref ConnectionAuthorizerArns]
|
|
1518
|
+
- '"],"controlPlanes":'
|
|
1519
|
+
- '[]'
|
|
1520
|
+
- '}'
|
|
1521
|
+
|
|
1071
1522
|
Outputs:
|
|
1072
1523
|
DeploymentRoleArn:
|
|
1073
|
-
Description: Cross-account deployment role the SaaSLayer control
|
|
1524
|
+
Description: Cross-account deployment role the managing SaaSLayer control planes assume (trust identifier required).
|
|
1074
1525
|
Value: !GetAtt SaaSLayerDeploymentRole.Arn
|
|
1075
1526
|
SupportReadOnlyRoleArn:
|
|
1076
|
-
Description: Cross-account read-only role SaaSLayer support staff assume for diagnostics (
|
|
1527
|
+
Description: Cross-account read-only role SaaSLayer support staff assume for diagnostics (trust identifier required).
|
|
1077
1528
|
Value: !GetAtt SaaSLayerSupportReadOnlyRole.Arn
|
|
1078
1529
|
CloudFormationExecutionRoleArn:
|
|
1079
1530
|
Description: Service role CloudFormation uses to provision approved SaaSLayer module stacks; not assumable cross-account.
|