saaslayer 0.0.1
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/LICENSE +17 -0
- package/README.md +63 -0
- package/bin/saaslayer.js +107 -0
- package/package.json +45 -0
- package/templates/host-account.yml +761 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2026 David Wells. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its source code are proprietary and confidential.
|
|
4
|
+
|
|
5
|
+
No license, right, or permission is granted to any person or entity to use,
|
|
6
|
+
copy, modify, merge, publish, distribute, sublicense, or sell copies of this
|
|
7
|
+
software, in whole or in part, without the prior written consent of the
|
|
8
|
+
copyright holder.
|
|
9
|
+
|
|
10
|
+
Unauthorized use, reproduction, or distribution is strictly prohibited.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
|
|
16
|
+
IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN
|
|
17
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# saaslayer
|
|
2
|
+
|
|
3
|
+
SaaSLayer onboarding CLI. Bootstrap an AWS account for the SaaSLayer control plane and register a service's RBAC manifest.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g saaslayer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx saaslayer --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Node.js >= 18. The `init` command shells out to the [AWS CLI](https://aws.amazon.com/cli/), which must be installed and authenticated.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
### `saaslayer init`
|
|
22
|
+
|
|
23
|
+
Deploy the host-account bootstrap (3 IAM roles + permissions boundary + artifact bucket) into the caller's AWS account, trusting the SaaSLayer control plane. Uses the bundled `templates/host-account.yml`.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
saaslayer init \
|
|
27
|
+
--control-plane-account <12-digit-account-id> \
|
|
28
|
+
--external-id <secret> \
|
|
29
|
+
[--stack-name saaslayer-host-account] \
|
|
30
|
+
[--region us-east-1] \
|
|
31
|
+
[--stack-name-prefix sl-] \
|
|
32
|
+
[--template PATH] \
|
|
33
|
+
[--dry-run]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Flag | Env | Description |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `--control-plane-account` | `SAASLAYER_CONTROL_PLANE_ACCOUNT` | 12-digit AWS account id allowed to assume the deploy role. Required. |
|
|
39
|
+
| `--external-id` | `SAASLAYER_EXTERNAL_ID` | Trust secret shared during onboarding. Required. |
|
|
40
|
+
| `--stack-name` | — | CloudFormation stack name. Defaults to `saaslayer-host-account`. |
|
|
41
|
+
| `--region` | `AWS_REGION` | Deploy region. Defaults to `us-east-1`. |
|
|
42
|
+
| `--stack-name-prefix` | — | Prefix for provisioned resources. Defaults to `sl-`. |
|
|
43
|
+
| `--template` | — | Override the bundled template path. |
|
|
44
|
+
| `--dry-run` | — | Validate the template only; deploy nothing. |
|
|
45
|
+
|
|
46
|
+
### `saaslayer rbac register <manifest.json>`
|
|
47
|
+
|
|
48
|
+
Upsert a service's `rbac.manifest.json` into the RBAC catalog (`POST /catalog/register`). Run by a human or wired into CI.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
saaslayer rbac register ./rbac.manifest.json \
|
|
52
|
+
--api-base https://api.example.com \
|
|
53
|
+
[--token $SAASLAYER_TOKEN]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
| Flag | Env | Description |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `--api-base` | `SAASLAYER_API_BASE` | RBAC catalog API base URL. Required. |
|
|
59
|
+
| `--token` | `SAASLAYER_TOKEN` | API key. Required. |
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
Proprietary. All rights reserved. See [LICENSE](./LICENSE).
|
package/bin/saaslayer.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SaaSLayer CLI (M0.10, D18) — onboard an AWS account and register RBAC manifests.
|
|
3
|
+
// `saaslayer init` deploys the bundled host-account.yml (the control plane's deploy role +
|
|
4
|
+
// boundary + artifact bucket). `saaslayer rbac register` upserts a service's rbac.manifest.json
|
|
5
|
+
// into the RBAC catalog (POST /catalog/register) — run by a human or wired into CI.
|
|
6
|
+
|
|
7
|
+
'use strict'
|
|
8
|
+
const fs = require('fs')
|
|
9
|
+
const path = require('path')
|
|
10
|
+
const { execFileSync } = require('child_process')
|
|
11
|
+
|
|
12
|
+
function parseArgs(argv) {
|
|
13
|
+
const positional = []
|
|
14
|
+
const flags = {}
|
|
15
|
+
for (let i = 0; i < argv.length; i++) {
|
|
16
|
+
const a = argv[i]
|
|
17
|
+
if (a.startsWith('--')) {
|
|
18
|
+
const key = a.slice(2)
|
|
19
|
+
const next = argv[i + 1]
|
|
20
|
+
if (next === undefined || next.startsWith('--')) { flags[key] = true } else { flags[key] = next; i++ }
|
|
21
|
+
} else { positional.push(a) }
|
|
22
|
+
}
|
|
23
|
+
return { positional, flags }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const HELP = `saaslayer — SaaSLayer onboarding CLI
|
|
27
|
+
|
|
28
|
+
Usage:
|
|
29
|
+
saaslayer init --control-plane-account <12-digit> --external-id <secret> [--stack-name NAME]
|
|
30
|
+
[--region REGION] [--stack-name-prefix sl-] [--template PATH] [--dry-run]
|
|
31
|
+
Deploy the host-account bootstrap (3 IAM roles + permissions boundary + artifact
|
|
32
|
+
bucket) into the caller's AWS account, trusting the SaaSLayer control plane.
|
|
33
|
+
Uses the bundled templates/host-account.yml. --dry-run validates only.
|
|
34
|
+
|
|
35
|
+
saaslayer rbac register <manifest.json> --api-base URL [--token KEY]
|
|
36
|
+
Upsert a service's rbac.manifest.json into the RBAC catalog.
|
|
37
|
+
--token defaults to $SAASLAYER_TOKEN.
|
|
38
|
+
|
|
39
|
+
Global:
|
|
40
|
+
--help Show this help.`
|
|
41
|
+
|
|
42
|
+
async function cmdRegister({ positional, flags }) {
|
|
43
|
+
const manifestPath = positional[0]
|
|
44
|
+
if (!manifestPath) throw new Error('rbac register: a manifest path is required')
|
|
45
|
+
const apiBase = flags['api-base'] || process.env.SAASLAYER_API_BASE
|
|
46
|
+
const token = flags.token || process.env.SAASLAYER_TOKEN
|
|
47
|
+
if (!apiBase) throw new Error('rbac register: --api-base (or $SAASLAYER_API_BASE) is required')
|
|
48
|
+
if (!token) throw new Error('rbac register: --token (or $SAASLAYER_TOKEN) is required')
|
|
49
|
+
const manifest = JSON.parse(fs.readFileSync(path.resolve(manifestPath), 'utf8'))
|
|
50
|
+
const res = await fetch(`${apiBase.replace(/\/$/, '')}/catalog/register`, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: { 'x-api-key': token, authorization: `Bearer ${token}`, 'content-type': 'application/json' },
|
|
53
|
+
body: JSON.stringify(manifest),
|
|
54
|
+
})
|
|
55
|
+
const body = await res.json().catch(() => ({}))
|
|
56
|
+
if (!res.ok) throw new Error(`register failed (${res.status}): ${JSON.stringify(body.errors || body)}`)
|
|
57
|
+
const a = body.data && body.data.attributes
|
|
58
|
+
console.log(`registered "${(a && a.service) || manifest.service}" (${(a && a.resourceCount) || '?'} resource types)`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function cmdInit({ flags }) {
|
|
62
|
+
const template = flags.template || path.join(__dirname, '..', 'templates', 'host-account.yml')
|
|
63
|
+
if (!fs.existsSync(template)) throw new Error(`init: template not found at ${template}`)
|
|
64
|
+
const region = flags.region || process.env.AWS_REGION || 'us-east-1'
|
|
65
|
+
// Canonical name — matches the deployer's bootstrap so init updates the same stack
|
|
66
|
+
// (the account-global named IAM resources allow only one host-account stack per account).
|
|
67
|
+
const stackName = flags['stack-name'] || 'saaslayer-host-bootstrap'
|
|
68
|
+
if (flags['dry-run']) {
|
|
69
|
+
execFileSync('aws', ['cloudformation', 'validate-template', '--template-body', `file://${template}`, '--region', region], { stdio: 'inherit' })
|
|
70
|
+
console.log(`\n[dry-run] template valid. Would deploy stack "${stackName}" to ${region}.`)
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
// Required params: the SaaSLayer control-plane account that may assume the deploy role,
|
|
74
|
+
// and the ExternalId trust secret shared during onboarding.
|
|
75
|
+
const controlPlaneAccount = flags['control-plane-account'] || process.env.SAASLAYER_CONTROL_PLANE_ACCOUNT
|
|
76
|
+
const externalId = flags['external-id'] || process.env.SAASLAYER_EXTERNAL_ID
|
|
77
|
+
const stackPrefix = flags['stack-name-prefix'] || 'sl-'
|
|
78
|
+
if (!controlPlaneAccount) throw new Error('init: --control-plane-account <12-digit id> (or $SAASLAYER_CONTROL_PLANE_ACCOUNT) is required')
|
|
79
|
+
if (!/^[0-9]{12}$/.test(controlPlaneAccount)) throw new Error('init: --control-plane-account must be a 12-digit AWS account id')
|
|
80
|
+
if (!externalId) throw new Error('init: --external-id <secret> (or $SAASLAYER_EXTERNAL_ID) is required — shared during onboarding')
|
|
81
|
+
console.log(`Deploying host-account stack "${stackName}" to ${region} (control plane ${controlPlaneAccount})…`)
|
|
82
|
+
execFileSync('aws', [
|
|
83
|
+
'cloudformation', 'deploy', '--template-file', template, '--stack-name', stackName, '--region', region,
|
|
84
|
+
'--capabilities', 'CAPABILITY_NAMED_IAM',
|
|
85
|
+
'--parameter-overrides',
|
|
86
|
+
`ControlPlaneAccountId=${controlPlaneAccount}`, `ExternalId=${externalId}`, `StackNamePrefix=${stackPrefix}`,
|
|
87
|
+
], { stdio: 'inherit' })
|
|
88
|
+
console.log('\nhost-account bootstrap deployed.')
|
|
89
|
+
console.log(` • Control plane ${controlPlaneAccount} may now assume the deploy role (ExternalId gated).`)
|
|
90
|
+
console.log(` • It can manage only CloudFormation stacks named "${stackPrefix}*" in this account.`)
|
|
91
|
+
console.log(' • Share the ControlPlaneAccountId + ExternalId with SaaSLayer onboarding to finish setup.')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function main() {
|
|
95
|
+
const argv = process.argv.slice(2)
|
|
96
|
+
const { positional, flags } = parseArgs(argv)
|
|
97
|
+
if (flags.help || positional.length === 0) { console.log(HELP); return }
|
|
98
|
+
const [cmd, sub] = positional
|
|
99
|
+
try {
|
|
100
|
+
if (cmd === 'init') return cmdInit({ flags })
|
|
101
|
+
if (cmd === 'rbac' && sub === 'register') return await cmdRegister({ positional: positional.slice(2), flags })
|
|
102
|
+
console.error(`Unknown command: ${positional.join(' ')}\n`); console.log(HELP); process.exit(1)
|
|
103
|
+
} catch (err) {
|
|
104
|
+
console.error(`error: ${err.message}`); process.exit(1)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
main()
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "saaslayer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SaaSLayer CLI \u2014 onboard an account (init) and register a service's RBAC manifest.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"saaslayer": "bin/saaslayer.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"templates",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"license": "UNLICENSED",
|
|
19
|
+
"author": "David Wells",
|
|
20
|
+
"homepage": "https://github.com/DavidWells/saaslayer/tree/master/packages/cli#readme",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/DavidWells/saaslayer.git",
|
|
24
|
+
"directory": "packages/cli"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/DavidWells/saaslayer/issues"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"saaslayer",
|
|
31
|
+
"cli",
|
|
32
|
+
"rbac",
|
|
33
|
+
"aws",
|
|
34
|
+
"cloudformation",
|
|
35
|
+
"onboarding"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "node bin/saaslayer.js --help >/dev/null && echo ok",
|
|
42
|
+
"sync-template": "node scripts/sync-template.js",
|
|
43
|
+
"prepublishOnly": "node scripts/sync-template.js"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
# SaaSLayer host-account bootstrap. Installed once per host (customer) account; grants the
|
|
2
|
+
# SaaSLayer control plane the minimum access needed to deploy and support SaaSLayer modules.
|
|
3
|
+
#
|
|
4
|
+
# SECURITY REVIEWER SUMMARY
|
|
5
|
+
#
|
|
6
|
+
# This template creates one S3 bucket, one permissions-boundary managed policy, and three IAM roles:
|
|
7
|
+
#
|
|
8
|
+
# 1. SaaSLayerDeploymentRole — the only cross-account WRITE entry point. Assumable solely by the
|
|
9
|
+
# SaaSLayer control-plane account (ControlPlaneAccountId parameter) and only with the shared
|
|
10
|
+
# ExternalId. It can drive the CloudFormation lifecycle of stacks whose names start with
|
|
11
|
+
# StackNamePrefix (default "sl-"), read/write the deployment artifact buckets, and pass exactly
|
|
12
|
+
# one role (SaaSLayerCloudFormationExecutionRole) to CloudFormation. It cannot create IAM
|
|
13
|
+
# resources or touch anything outside the managed stack namespace directly.
|
|
14
|
+
#
|
|
15
|
+
# 2. SaaSLayerCloudFormationExecutionRole — assumable ONLY by the CloudFormation service, never
|
|
16
|
+
# cross-account. CloudFormation uses it to create/update/delete the resources declared by
|
|
17
|
+
# approved SaaSLayer module templates. Its permissions are the provisioning verbs derived from
|
|
18
|
+
# the module resource inventory (see per-statement comments below). Because only
|
|
19
|
+
# SaaSLayerDeploymentRole can pass this role, it is reachable exclusively through the audited
|
|
20
|
+
# stack lifecycle above.
|
|
21
|
+
#
|
|
22
|
+
# 3. SaaSLayerSupportReadOnlyRole — a separate cross-account READ-ONLY role for SaaSLayer support
|
|
23
|
+
# staff. Same account + ExternalId trust gate as the deployment role, plus an enforced
|
|
24
|
+
# "saaslayer-support-*" session-name pattern so every assumption is attributable in CloudTrail.
|
|
25
|
+
# It carries only Get/List/Describe verbs, is tag-scoped to resources carrying
|
|
26
|
+
# managed-by=saaslayer-deployer where IAM supports resource-tag conditions, and deliberately
|
|
27
|
+
# excludes all data-plane reads (no S3 object reads, no DynamoDB item reads, no SSM parameter
|
|
28
|
+
# values, no Secrets Manager secret values).
|
|
29
|
+
#
|
|
30
|
+
# SaaSLayerManagedResourceBoundary is a permissions boundary attached to every IAM role that
|
|
31
|
+
# SaaSLayer module templates create: whatever a module role's own policy says, its effective
|
|
32
|
+
# runtime permissions can never exceed this boundary.
|
|
33
|
+
#
|
|
34
|
+
# Every deployed SaaSLayer stack tags its resources with managed-by=saaslayer-deployer,
|
|
35
|
+
# deploymentId, customerId, and moduleName for inventory and audit.
|
|
36
|
+
#
|
|
37
|
+
# Contract tests for this template live at tests/bootstrap.test.js (read-only guarantee for the
|
|
38
|
+
# support role, external-id enforcement, wildcard justification audit).
|
|
39
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
|
40
|
+
Description: >-
|
|
41
|
+
SaaSLayer host-account bootstrap: deployment artifact bucket, CloudFormation execution role for
|
|
42
|
+
approved SaaSLayer module templates, permissions boundary for module-created IAM roles, a
|
|
43
|
+
cross-account deployment role restricted to SaaSLayer-prefixed stacks, and a cross-account
|
|
44
|
+
read-only support role. Both cross-account roles require an external ID and trust only the
|
|
45
|
+
SaaSLayer control-plane account supplied as a parameter.
|
|
46
|
+
|
|
47
|
+
Parameters:
|
|
48
|
+
ControlPlaneAccountId:
|
|
49
|
+
Type: String
|
|
50
|
+
AllowedPattern: '^[0-9]{12}$'
|
|
51
|
+
Description: >-
|
|
52
|
+
AWS account ID that runs the SaaSLayer deployer control plane. This is the only account the
|
|
53
|
+
cross-account roles in this template trust.
|
|
54
|
+
ExternalId:
|
|
55
|
+
Type: String
|
|
56
|
+
NoEcho: true
|
|
57
|
+
Description: >-
|
|
58
|
+
External ID required when assuming SaaSLayerDeploymentRole or SaaSLayerSupportReadOnlyRole.
|
|
59
|
+
Shared out-of-band during onboarding; assume-role calls without it are denied.
|
|
60
|
+
StackNamePrefix:
|
|
61
|
+
Type: String
|
|
62
|
+
Default: sl-
|
|
63
|
+
Description: >-
|
|
64
|
+
Prefix for SaaSLayer-managed CloudFormation stacks. The deployment role can only operate on
|
|
65
|
+
stacks whose names start with this prefix.
|
|
66
|
+
EnableEmailInbound:
|
|
67
|
+
Type: String
|
|
68
|
+
AllowedValues: ['true', 'false']
|
|
69
|
+
Default: 'false'
|
|
70
|
+
Description: >-
|
|
71
|
+
When 'true', grant the SES receipt-rule provisioning + inbound-mail runtime permissions that
|
|
72
|
+
email-inbound-service needs. Default 'false' so host accounts that do NOT run email-inbound are
|
|
73
|
+
not over-permissioned for SES. The deployer sets this per host based on the services it hosts.
|
|
74
|
+
|
|
75
|
+
Conditions:
|
|
76
|
+
# Gate email-inbound-service's SES permissions so they exist only on host accounts that run it.
|
|
77
|
+
EmailInboundEnabled: !Equals [!Ref EnableEmailInbound, 'true']
|
|
78
|
+
|
|
79
|
+
Resources:
|
|
80
|
+
# Private, encrypted bucket for packaged module templates and lambda artifacts uploaded by the
|
|
81
|
+
# deployer. Only the deployment role reads/writes it (see saaslayer-stack-lifecycle below).
|
|
82
|
+
DeploymentArtifactBucket:
|
|
83
|
+
Type: AWS::S3::Bucket
|
|
84
|
+
Properties:
|
|
85
|
+
PublicAccessBlockConfiguration:
|
|
86
|
+
BlockPublicAcls: true
|
|
87
|
+
BlockPublicPolicy: true
|
|
88
|
+
IgnorePublicAcls: true
|
|
89
|
+
RestrictPublicBuckets: true
|
|
90
|
+
BucketEncryption:
|
|
91
|
+
ServerSideEncryptionConfiguration:
|
|
92
|
+
- ServerSideEncryptionByDefault:
|
|
93
|
+
SSEAlgorithm: AES256
|
|
94
|
+
|
|
95
|
+
# Service role CloudFormation assumes while creating/updating/deleting resources declared by
|
|
96
|
+
# approved SaaSLayer module templates. Not assumable by any AWS account — only the CloudFormation
|
|
97
|
+
# service — and only reachable via SaaSLayerDeploymentRole's scoped iam:PassRole. Actions below
|
|
98
|
+
# are the provisioning verbs for the module resource inventory (API Gateway REST APIs, Cognito
|
|
99
|
+
# user/identity pools, DynamoDB tables, EventBridge buses, Lambda functions, log groups,
|
|
100
|
+
# schedules, secrets, buckets, SSM parameters, queues) plus the IAM verbs for the roles/policies
|
|
101
|
+
# those templates declare.
|
|
102
|
+
SaaSLayerCloudFormationExecutionRole:
|
|
103
|
+
Type: AWS::IAM::Role
|
|
104
|
+
Properties:
|
|
105
|
+
RoleName: SaaSLayerCloudFormationExecutionRole
|
|
106
|
+
AssumeRolePolicyDocument:
|
|
107
|
+
Version: '2012-10-17'
|
|
108
|
+
Statement:
|
|
109
|
+
- Effect: Allow
|
|
110
|
+
Principal:
|
|
111
|
+
Service: cloudformation.amazonaws.com
|
|
112
|
+
Action: sts:AssumeRole
|
|
113
|
+
Policies:
|
|
114
|
+
- PolicyName: saaslayer-approved-template-execution
|
|
115
|
+
PolicyDocument:
|
|
116
|
+
Version: '2012-10-17'
|
|
117
|
+
Statement:
|
|
118
|
+
# Provisioning verbs per service. Several AWS create/list APIs only accept
|
|
119
|
+
# Resource '*'; resource-name namespacing work to tighten this is tracked in
|
|
120
|
+
# docs/permissions-hardening.md.
|
|
121
|
+
- Effect: Allow
|
|
122
|
+
Action:
|
|
123
|
+
# API Gateway IAM actions are bare HTTP verbs against untyped resource paths;
|
|
124
|
+
# REST API provisioning (methods, resources, deployments, stages, authorizers)
|
|
125
|
+
# exercises all of them. Justified service wildcard (tests/bootstrap.test.js).
|
|
126
|
+
- apigateway:*
|
|
127
|
+
# Stack introspection while executing changesets (read-only verbs).
|
|
128
|
+
- cloudformation:Describe*
|
|
129
|
+
- cloudformation:Get*
|
|
130
|
+
- cloudformation:List*
|
|
131
|
+
# CloudWatch alarm + dashboard lifecycle for module observability resources.
|
|
132
|
+
- cloudwatch:DeleteAlarms
|
|
133
|
+
- cloudwatch:DeleteDashboards
|
|
134
|
+
- cloudwatch:DescribeAlarms
|
|
135
|
+
- cloudwatch:DisableAlarmActions
|
|
136
|
+
- cloudwatch:EnableAlarmActions
|
|
137
|
+
- cloudwatch:GetDashboard
|
|
138
|
+
- cloudwatch:ListDashboards
|
|
139
|
+
- cloudwatch:PutDashboard
|
|
140
|
+
- cloudwatch:PutMetricAlarm
|
|
141
|
+
- cloudwatch:TagResource
|
|
142
|
+
- cloudwatch:UntagResource
|
|
143
|
+
# CloudFront distribution + origin-access-control lifecycle for static-site modules
|
|
144
|
+
# (rbac-admin-ui: private S3 origin + OAC). CreateDistribution/OAC cannot be
|
|
145
|
+
# resource-scoped, so these sit in the Resource:'*' statement. CreateInvalidation
|
|
146
|
+
# busts the edge cache when a redeploy uploads a new SPA build.
|
|
147
|
+
- cloudfront:CreateDistribution
|
|
148
|
+
- cloudfront:CreateInvalidation
|
|
149
|
+
- cloudfront:CreateOriginAccessControl
|
|
150
|
+
- cloudfront:DeleteDistribution
|
|
151
|
+
- cloudfront:DeleteOriginAccessControl
|
|
152
|
+
- cloudfront:GetDistribution
|
|
153
|
+
- cloudfront:GetDistributionConfig
|
|
154
|
+
- cloudfront:GetOriginAccessControl
|
|
155
|
+
- cloudfront:ListTagsForResource
|
|
156
|
+
- cloudfront:TagResource
|
|
157
|
+
- cloudfront:UntagResource
|
|
158
|
+
- cloudfront:UpdateDistribution
|
|
159
|
+
- cloudfront:UpdateOriginAccessControl
|
|
160
|
+
# SNS topic lifecycle: module stacks create an ops-alarms topic that
|
|
161
|
+
# alarms publish to (lean health checks). Full lifecycle so
|
|
162
|
+
# CloudFormation can create/read/tag/delete the managed topics.
|
|
163
|
+
- sns:CreateTopic
|
|
164
|
+
- sns:DeleteTopic
|
|
165
|
+
- sns:GetTopicAttributes
|
|
166
|
+
- sns:SetTopicAttributes
|
|
167
|
+
- sns:Subscribe
|
|
168
|
+
- sns:Unsubscribe
|
|
169
|
+
- sns:ListSubscriptionsByTopic
|
|
170
|
+
- sns:TagResource
|
|
171
|
+
- sns:UntagResource
|
|
172
|
+
# Cognito identity pool + user pool lifecycle (user-service module). Their
|
|
173
|
+
# CloudFormation handlers exercise a broad, shifting action set; kept as
|
|
174
|
+
# justified service wildcards until enumerated (docs/permissions-hardening.md).
|
|
175
|
+
- cognito-identity:*
|
|
176
|
+
- cognito-idp:*
|
|
177
|
+
# DynamoDB table lifecycle (provisioning verbs only — no item read/write).
|
|
178
|
+
- dynamodb:CreateTable
|
|
179
|
+
- dynamodb:DeleteTable
|
|
180
|
+
- dynamodb:DescribeContinuousBackups
|
|
181
|
+
- dynamodb:DescribeContributorInsights
|
|
182
|
+
- dynamodb:DescribeTable
|
|
183
|
+
- dynamodb:DescribeTimeToLive
|
|
184
|
+
- dynamodb:ListTagsOfResource
|
|
185
|
+
- dynamodb:TagResource
|
|
186
|
+
- dynamodb:UntagResource
|
|
187
|
+
- dynamodb:UpdateContinuousBackups
|
|
188
|
+
- dynamodb:UpdateContributorInsights
|
|
189
|
+
- dynamodb:UpdateTable
|
|
190
|
+
- dynamodb:UpdateTimeToLive
|
|
191
|
+
# EventBridge custom event bus lifecycle (module event buses) + rule lifecycle for
|
|
192
|
+
# scheduled Lambdas (serverless `schedule` events generate AWS::Events::Rule — e.g.
|
|
193
|
+
# rbac-service's event-delivery poller). DescribeRule/PutRule/*Targets are required
|
|
194
|
+
# or the rule CREATE fails with AccessDenied.
|
|
195
|
+
- events:CreateEventBus
|
|
196
|
+
- events:DeleteEventBus
|
|
197
|
+
- events:DeleteRule
|
|
198
|
+
- events:DescribeEventBus
|
|
199
|
+
- events:DescribeRule
|
|
200
|
+
- events:DisableRule
|
|
201
|
+
- events:EnableRule
|
|
202
|
+
- events:ListTagsForResource
|
|
203
|
+
- events:ListTargetsByRule
|
|
204
|
+
- events:PutPermission
|
|
205
|
+
- events:PutRule
|
|
206
|
+
- events:PutTargets
|
|
207
|
+
- events:RemovePermission
|
|
208
|
+
- events:RemoveTargets
|
|
209
|
+
- events:TagResource
|
|
210
|
+
- events:UntagResource
|
|
211
|
+
# IAM role/policy lifecycle for the roles module templates declare (lambda
|
|
212
|
+
# execution roles, scheduler roles). Runtime permissions of created roles are
|
|
213
|
+
# capped by SaaSLayerManagedResourceBoundary.
|
|
214
|
+
- iam:CreatePolicy
|
|
215
|
+
- iam:CreatePolicyVersion
|
|
216
|
+
- iam:CreateRole
|
|
217
|
+
- iam:DeletePolicy
|
|
218
|
+
- iam:DeletePolicyVersion
|
|
219
|
+
- iam:DeleteRole
|
|
220
|
+
- iam:DeleteRolePolicy
|
|
221
|
+
- iam:DetachRolePolicy
|
|
222
|
+
- iam:AttachRolePolicy
|
|
223
|
+
- iam:GetPolicy
|
|
224
|
+
- iam:GetPolicyVersion
|
|
225
|
+
- iam:GetRole
|
|
226
|
+
- iam:GetRolePolicy
|
|
227
|
+
- iam:ListAttachedRolePolicies
|
|
228
|
+
- iam:ListEntitiesForPolicy
|
|
229
|
+
- iam:ListPolicyVersions
|
|
230
|
+
- iam:ListRolePolicies
|
|
231
|
+
- iam:PassRole
|
|
232
|
+
- iam:PutRolePolicy
|
|
233
|
+
- iam:SetDefaultPolicyVersion
|
|
234
|
+
- iam:TagPolicy
|
|
235
|
+
- iam:TagRole
|
|
236
|
+
- iam:UntagPolicy
|
|
237
|
+
- iam:UntagRole
|
|
238
|
+
- iam:UpdateAssumeRolePolicy
|
|
239
|
+
- iam:UpdateRole
|
|
240
|
+
- iam:UpdateRoleDescription
|
|
241
|
+
# KMS customer-managed key + alias lifecycle. rbac-service provisions an
|
|
242
|
+
# EventDeliveryKey (AWS::KMS::Key, rotation on) + alias for webhook payload
|
|
243
|
+
# encryption; CreateKey mandates Resource '*', and TagResource on the new key
|
|
244
|
+
# is required or CloudFormation fails with UnauthorizedTaggingOperation.
|
|
245
|
+
- kms:CreateAlias
|
|
246
|
+
- kms:CreateKey
|
|
247
|
+
- kms:DeleteAlias
|
|
248
|
+
- kms:DescribeKey
|
|
249
|
+
- kms:DisableKeyRotation
|
|
250
|
+
- kms:EnableKeyRotation
|
|
251
|
+
- kms:GetKeyPolicy
|
|
252
|
+
- kms:GetKeyRotationStatus
|
|
253
|
+
- kms:ListResourceTags
|
|
254
|
+
- kms:PutKeyPolicy
|
|
255
|
+
- kms:ScheduleKeyDeletion
|
|
256
|
+
- kms:TagResource
|
|
257
|
+
- kms:UntagResource
|
|
258
|
+
- kms:UpdateAlias
|
|
259
|
+
# Lambda function/layer/alias/event-source lifecycle. lambda:InvokeFunction is
|
|
260
|
+
# required because module templates use CloudFormation custom resources
|
|
261
|
+
# (Custom::Delay in user-service) that CloudFormation invokes during deploys.
|
|
262
|
+
- lambda:AddPermission
|
|
263
|
+
- lambda:CreateEventSourceMapping
|
|
264
|
+
- lambda:CreateFunction
|
|
265
|
+
- lambda:DeleteEventSourceMapping
|
|
266
|
+
- lambda:DeleteFunction
|
|
267
|
+
- lambda:DeleteFunctionConcurrency
|
|
268
|
+
- lambda:DeleteFunctionEventInvokeConfig
|
|
269
|
+
- lambda:DeleteLayerVersion
|
|
270
|
+
- lambda:DeleteProvisionedConcurrencyConfig
|
|
271
|
+
- lambda:GetAccountSettings
|
|
272
|
+
- lambda:GetAlias
|
|
273
|
+
- lambda:GetEventSourceMapping
|
|
274
|
+
- lambda:GetFunction
|
|
275
|
+
- lambda:GetFunctionCodeSigningConfig
|
|
276
|
+
- lambda:GetFunctionConcurrency
|
|
277
|
+
- lambda:GetFunctionConfiguration
|
|
278
|
+
- lambda:GetFunctionEventInvokeConfig
|
|
279
|
+
- lambda:GetLayerVersion
|
|
280
|
+
- lambda:GetPolicy
|
|
281
|
+
- lambda:GetProvisionedConcurrencyConfig
|
|
282
|
+
- lambda:GetRuntimeManagementConfig
|
|
283
|
+
- lambda:InvokeFunction
|
|
284
|
+
- lambda:ListAliases
|
|
285
|
+
- lambda:ListEventSourceMappings
|
|
286
|
+
- lambda:ListFunctions
|
|
287
|
+
- lambda:ListLayerVersions
|
|
288
|
+
- lambda:ListTags
|
|
289
|
+
- lambda:ListVersionsByFunction
|
|
290
|
+
- lambda:PublishLayerVersion
|
|
291
|
+
- lambda:PublishVersion
|
|
292
|
+
- lambda:PutFunctionCodeSigningConfig
|
|
293
|
+
- lambda:PutFunctionConcurrency
|
|
294
|
+
- lambda:PutFunctionEventInvokeConfig
|
|
295
|
+
- lambda:PutProvisionedConcurrencyConfig
|
|
296
|
+
- lambda:RemovePermission
|
|
297
|
+
- lambda:TagResource
|
|
298
|
+
- lambda:UntagResource
|
|
299
|
+
- lambda:UpdateAlias
|
|
300
|
+
- lambda:UpdateEventSourceMapping
|
|
301
|
+
- lambda:UpdateFunctionCode
|
|
302
|
+
- lambda:UpdateFunctionConfiguration
|
|
303
|
+
# Log group lifecycle for module functions/services. The LogDelivery and
|
|
304
|
+
# resource-policy verbs support AWS::Cognito::LogDeliveryConfiguration
|
|
305
|
+
# (user-service auth event logging).
|
|
306
|
+
- logs:CreateLogDelivery
|
|
307
|
+
- logs:CreateLogGroup
|
|
308
|
+
- logs:CreateLogStream
|
|
309
|
+
- logs:DeleteLogDelivery
|
|
310
|
+
- logs:DeleteLogGroup
|
|
311
|
+
- logs:DeleteLogStream
|
|
312
|
+
- logs:DeleteRetentionPolicy
|
|
313
|
+
- logs:DescribeIndexPolicies
|
|
314
|
+
- logs:DescribeLogGroups
|
|
315
|
+
- logs:DescribeLogStreams
|
|
316
|
+
- logs:DescribeResourcePolicies
|
|
317
|
+
- logs:GetLogDelivery
|
|
318
|
+
- logs:ListLogDeliveries
|
|
319
|
+
- logs:ListTagsForResource
|
|
320
|
+
- logs:PutDestination
|
|
321
|
+
- logs:PutDestinationPolicy
|
|
322
|
+
- logs:PutLogEvents
|
|
323
|
+
- logs:PutResourcePolicy
|
|
324
|
+
- logs:PutRetentionPolicy
|
|
325
|
+
- logs:TagLogGroup
|
|
326
|
+
- logs:TagResource
|
|
327
|
+
- logs:UntagLogGroup
|
|
328
|
+
- logs:UntagResource
|
|
329
|
+
- logs:UpdateLogDelivery
|
|
330
|
+
# EventBridge Scheduler lifecycle for module-declared schedules (rbac-core
|
|
331
|
+
# delegation expiry uses schedules; runtime CRUD is granted via the boundary).
|
|
332
|
+
- scheduler:CreateSchedule
|
|
333
|
+
- scheduler:CreateScheduleGroup
|
|
334
|
+
- scheduler:DeleteSchedule
|
|
335
|
+
- scheduler:DeleteScheduleGroup
|
|
336
|
+
- scheduler:GetSchedule
|
|
337
|
+
- scheduler:GetScheduleGroup
|
|
338
|
+
- scheduler:ListTagsForResource
|
|
339
|
+
- scheduler:TagResource
|
|
340
|
+
- scheduler:UntagResource
|
|
341
|
+
- scheduler:UpdateSchedule
|
|
342
|
+
# Secrets Manager secret lifecycle (AWS::SecretsManager::Secret in modules).
|
|
343
|
+
# No GetSecretValue: this role provisions secrets, it cannot read their values.
|
|
344
|
+
- secretsmanager:CreateSecret
|
|
345
|
+
- secretsmanager:DeleteResourcePolicy
|
|
346
|
+
- secretsmanager:DeleteSecret
|
|
347
|
+
- secretsmanager:DescribeSecret
|
|
348
|
+
- secretsmanager:GetResourcePolicy
|
|
349
|
+
- secretsmanager:PutResourcePolicy
|
|
350
|
+
- secretsmanager:PutSecretValue
|
|
351
|
+
- secretsmanager:RemoveRegionsFromReplication
|
|
352
|
+
- secretsmanager:ReplicateSecretToRegions
|
|
353
|
+
- secretsmanager:RestoreSecret
|
|
354
|
+
- secretsmanager:StopReplicationToReplica
|
|
355
|
+
- secretsmanager:TagResource
|
|
356
|
+
- secretsmanager:UntagResource
|
|
357
|
+
- secretsmanager:UpdateSecret
|
|
358
|
+
- secretsmanager:UpdateSecretVersionStage
|
|
359
|
+
# S3 bucket lifecycle + bucket configuration for module buckets, plus object
|
|
360
|
+
# read/write used while CloudFormation stages template artifacts.
|
|
361
|
+
- s3:CreateBucket
|
|
362
|
+
- s3:DeleteBucket
|
|
363
|
+
- s3:DeleteBucketPolicy
|
|
364
|
+
- s3:DeleteBucketWebsite
|
|
365
|
+
- s3:DeleteObject
|
|
366
|
+
- s3:GetAccelerateConfiguration
|
|
367
|
+
- s3:GetBucketAcl
|
|
368
|
+
- s3:GetBucketCORS
|
|
369
|
+
- s3:GetBucketLocation
|
|
370
|
+
- s3:GetBucketLogging
|
|
371
|
+
- s3:GetBucketNotification
|
|
372
|
+
- s3:GetBucketObjectLockConfiguration
|
|
373
|
+
- s3:GetBucketOwnershipControls
|
|
374
|
+
- s3:GetBucketPolicy
|
|
375
|
+
- s3:GetBucketPublicAccessBlock
|
|
376
|
+
- s3:GetBucketTagging
|
|
377
|
+
- s3:GetBucketVersioning
|
|
378
|
+
- s3:GetBucketWebsite
|
|
379
|
+
- s3:GetEncryptionConfiguration
|
|
380
|
+
- s3:GetLifecycleConfiguration
|
|
381
|
+
- s3:GetObject
|
|
382
|
+
- s3:ListBucket
|
|
383
|
+
- s3:PutAccelerateConfiguration
|
|
384
|
+
- s3:PutBucketAcl
|
|
385
|
+
- s3:PutBucketCORS
|
|
386
|
+
- s3:PutBucketLogging
|
|
387
|
+
- s3:PutBucketNotification
|
|
388
|
+
- s3:PutBucketObjectLockConfiguration
|
|
389
|
+
- s3:PutBucketOwnershipControls
|
|
390
|
+
- s3:PutBucketPolicy
|
|
391
|
+
- s3:PutBucketPublicAccessBlock
|
|
392
|
+
- s3:PutBucketTagging
|
|
393
|
+
- s3:PutBucketVersioning
|
|
394
|
+
- s3:PutBucketWebsite
|
|
395
|
+
- s3:PutEncryptionConfiguration
|
|
396
|
+
- s3:PutLifecycleConfiguration
|
|
397
|
+
- s3:PutObject
|
|
398
|
+
- s3:PutObjectAcl
|
|
399
|
+
# SSM parameter lifecycle for module configuration exports (AWS::SSM::Parameter).
|
|
400
|
+
- ssm:AddTagsToResource
|
|
401
|
+
- ssm:DeleteParameter
|
|
402
|
+
- ssm:DeleteParameters
|
|
403
|
+
- ssm:DescribeParameters
|
|
404
|
+
- ssm:GetParameter
|
|
405
|
+
- ssm:GetParameters
|
|
406
|
+
- ssm:GetParametersByPath
|
|
407
|
+
- ssm:ListTagsForResource
|
|
408
|
+
- ssm:PutParameter
|
|
409
|
+
- ssm:RemoveTagsFromResource
|
|
410
|
+
# SQS queue lifecycle (provisioning verbs only — no message send/receive).
|
|
411
|
+
- sqs:CreateQueue
|
|
412
|
+
- sqs:DeleteQueue
|
|
413
|
+
- sqs:GetQueueAttributes
|
|
414
|
+
- sqs:ListQueueTags
|
|
415
|
+
- sqs:SetQueueAttributes
|
|
416
|
+
- sqs:TagQueue
|
|
417
|
+
- sqs:UntagQueue
|
|
418
|
+
Resource: '*'
|
|
419
|
+
# SES receipt rule set/rule provisioning — only on hosts that run email-inbound
|
|
420
|
+
# (EnableEmailInbound=true). Identity verification (VerifyDomainIdentity/DKIM) runs
|
|
421
|
+
# CP-side in the domain-service, never from the tenant account.
|
|
422
|
+
- Fn::If:
|
|
423
|
+
- EmailInboundEnabled
|
|
424
|
+
- Effect: Allow
|
|
425
|
+
Action:
|
|
426
|
+
- ses:CreateReceiptRuleSet
|
|
427
|
+
- ses:DeleteReceiptRuleSet
|
|
428
|
+
- ses:CreateReceiptRule
|
|
429
|
+
- ses:DeleteReceiptRule
|
|
430
|
+
- ses:UpdateReceiptRule
|
|
431
|
+
- ses:DescribeReceiptRuleSet
|
|
432
|
+
- ses:DescribeReceiptRule
|
|
433
|
+
Resource: '*'
|
|
434
|
+
- !Ref AWS::NoValue
|
|
435
|
+
# Module templates use the AWS::LanguageExtensions transform; CloudFormation
|
|
436
|
+
# requires CreateChangeSet on the transform pseudo-resource to expand it.
|
|
437
|
+
- Effect: Allow
|
|
438
|
+
Action:
|
|
439
|
+
- cloudformation:CreateChangeSet
|
|
440
|
+
Resource: !Sub arn:${AWS::Partition}:cloudformation:${AWS::Region}:aws:transform/LanguageExtensions
|
|
441
|
+
|
|
442
|
+
# Permissions boundary attached to every IAM role created by SaaSLayer module templates (the
|
|
443
|
+
# deployer passes this policy's ARN into each module deploy). A module role's effective runtime
|
|
444
|
+
# permissions are the INTERSECTION of its own policy and this boundary, so even a template bug
|
|
445
|
+
# that attaches an over-broad policy cannot exceed the actions listed here. The actions are the
|
|
446
|
+
# runtime (data-plane) needs of the modules: Cognito admin user operations, DynamoDB item CRUD,
|
|
447
|
+
# event publishing, lambda-to-lambda invocation, log writing, Pinpoint/SNS messaging for auth
|
|
448
|
+
# flows, S3 object CRUD, schedule CRUD for delegation expiry, and SQS messaging.
|
|
449
|
+
SaaSLayerManagedResourceBoundary:
|
|
450
|
+
Type: AWS::IAM::ManagedPolicy
|
|
451
|
+
Properties:
|
|
452
|
+
ManagedPolicyName: SaaSLayerManagedResourceBoundary
|
|
453
|
+
Description: Maximum runtime permissions for IAM roles created by SaaSLayer managed stacks.
|
|
454
|
+
PolicyDocument:
|
|
455
|
+
Version: '2012-10-17'
|
|
456
|
+
Statement:
|
|
457
|
+
- Effect: Allow
|
|
458
|
+
Action:
|
|
459
|
+
- cognito-idp:AdminDeleteUserAttributes
|
|
460
|
+
- cognito-idp:AdminGetUser
|
|
461
|
+
- cognito-idp:AdminListGroupsForUser
|
|
462
|
+
- cognito-idp:AdminSetUserMFAPreference
|
|
463
|
+
- cognito-idp:AdminUpdateUserAttributes
|
|
464
|
+
- cognito-idp:GetUserPoolMfaConfig
|
|
465
|
+
- cognito-idp:ListUsers
|
|
466
|
+
- dynamodb:BatchGetItem
|
|
467
|
+
- dynamodb:BatchWriteItem
|
|
468
|
+
- dynamodb:DeleteItem
|
|
469
|
+
- dynamodb:DescribeStream
|
|
470
|
+
- dynamodb:DescribeTable
|
|
471
|
+
- dynamodb:GetItem
|
|
472
|
+
- dynamodb:GetRecords
|
|
473
|
+
- dynamodb:GetShardIterator
|
|
474
|
+
- dynamodb:ListStreams
|
|
475
|
+
- dynamodb:PutItem
|
|
476
|
+
- dynamodb:Query
|
|
477
|
+
- dynamodb:Scan
|
|
478
|
+
- dynamodb:UpdateItem
|
|
479
|
+
- events:PutEvents
|
|
480
|
+
- execute-api:Invoke
|
|
481
|
+
- iam:PassRole
|
|
482
|
+
- kms:Decrypt
|
|
483
|
+
- kms:DescribeKey
|
|
484
|
+
- kms:Encrypt
|
|
485
|
+
- kms:GenerateDataKey
|
|
486
|
+
- lambda:InvokeFunction
|
|
487
|
+
- logs:CreateLogGroup
|
|
488
|
+
- logs:CreateLogStream
|
|
489
|
+
- logs:PutLogEvents
|
|
490
|
+
- mobiletargeting:PutEvents
|
|
491
|
+
- s3:AbortMultipartUpload
|
|
492
|
+
- s3:DeleteObject
|
|
493
|
+
- s3:GetBucketLocation
|
|
494
|
+
- s3:GetObject
|
|
495
|
+
- s3:ListBucket
|
|
496
|
+
- s3:PutObject
|
|
497
|
+
- scheduler:CreateSchedule
|
|
498
|
+
- scheduler:DeleteSchedule
|
|
499
|
+
- scheduler:GetSchedule
|
|
500
|
+
- scheduler:UpdateSchedule
|
|
501
|
+
- sns:Publish
|
|
502
|
+
- sqs:DeleteMessage
|
|
503
|
+
- sqs:GetQueueAttributes
|
|
504
|
+
- sqs:GetQueueUrl
|
|
505
|
+
- sqs:ReceiveMessage
|
|
506
|
+
- sqs:SendMessage
|
|
507
|
+
- sqs:SendMessageBatch
|
|
508
|
+
Resource: '*'
|
|
509
|
+
# SES runtime (forward/notify sends + the active-rule-set custom resource) — only on hosts
|
|
510
|
+
# that run email-inbound. Receiving into S3 is granted to the ses.amazonaws.com service
|
|
511
|
+
# principal by the module's bucket policy, not here.
|
|
512
|
+
- Fn::If:
|
|
513
|
+
- EmailInboundEnabled
|
|
514
|
+
- Effect: Allow
|
|
515
|
+
Action:
|
|
516
|
+
- ses:DescribeActiveReceiptRuleSet
|
|
517
|
+
- ses:DescribeReceiptRuleSet
|
|
518
|
+
- ses:SendEmail
|
|
519
|
+
- ses:SendRawEmail
|
|
520
|
+
- ses:SetActiveReceiptRuleSet
|
|
521
|
+
Resource: '*'
|
|
522
|
+
- !Ref AWS::NoValue
|
|
523
|
+
|
|
524
|
+
# Cross-account WRITE entry point for the SaaSLayer control plane. Trust is double-gated: only
|
|
525
|
+
# the control-plane account, and only with the shared external ID. Every mutating grant is scoped
|
|
526
|
+
# to the SaaSLayer stack namespace (StackNamePrefix) or the deployment artifact buckets; resource
|
|
527
|
+
# creation itself always happens through CloudFormation with the execution role above.
|
|
528
|
+
SaaSLayerDeploymentRole:
|
|
529
|
+
Type: AWS::IAM::Role
|
|
530
|
+
Properties:
|
|
531
|
+
RoleName: SaaSLayerDeploymentRole
|
|
532
|
+
AssumeRolePolicyDocument:
|
|
533
|
+
Version: '2012-10-17'
|
|
534
|
+
Statement:
|
|
535
|
+
- Effect: Allow
|
|
536
|
+
Principal:
|
|
537
|
+
AWS: !Sub arn:aws:iam::${ControlPlaneAccountId}:root
|
|
538
|
+
Action: sts:AssumeRole
|
|
539
|
+
Condition:
|
|
540
|
+
StringEquals:
|
|
541
|
+
sts:ExternalId: !Ref ExternalId
|
|
542
|
+
Policies:
|
|
543
|
+
- PolicyName: saaslayer-stack-lifecycle
|
|
544
|
+
PolicyDocument:
|
|
545
|
+
Version: '2012-10-17'
|
|
546
|
+
Statement:
|
|
547
|
+
# Full stack lifecycle (create/update/delete via changesets), restricted to stacks
|
|
548
|
+
# in the SaaSLayer namespace. Stacks outside ${StackNamePrefix}* are untouchable.
|
|
549
|
+
- Effect: Allow
|
|
550
|
+
Action:
|
|
551
|
+
- cloudformation:CreateStack
|
|
552
|
+
- cloudformation:CreateChangeSet
|
|
553
|
+
- cloudformation:UpdateStack
|
|
554
|
+
- cloudformation:ExecuteChangeSet
|
|
555
|
+
- cloudformation:SetStackPolicy
|
|
556
|
+
- cloudformation:DeleteChangeSet
|
|
557
|
+
- cloudformation:DeleteStack
|
|
558
|
+
- cloudformation:Describe*
|
|
559
|
+
- cloudformation:Get*
|
|
560
|
+
# Drift gate (update runs refuse to apply over out-of-band edits):
|
|
561
|
+
# Detect* verbs sit outside Describe*/Get* and must be listed.
|
|
562
|
+
- cloudformation:DetectStackDrift
|
|
563
|
+
- cloudformation:DetectStackResourceDrift
|
|
564
|
+
Resource: !Sub arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackNamePrefix}*
|
|
565
|
+
# Actions the API cannot scope to a stack ARN: ValidateTemplate, and the
|
|
566
|
+
# drift-detection status poll which operates on a detection id, not a stack.
|
|
567
|
+
- Effect: Allow
|
|
568
|
+
Action:
|
|
569
|
+
- cloudformation:ValidateTemplate
|
|
570
|
+
- cloudformation:DescribeStackDriftDetectionStatus
|
|
571
|
+
Resource: '*'
|
|
572
|
+
# The single permitted pass-role path: this role may hand CloudFormation exactly one
|
|
573
|
+
# execution role. It cannot pass any other role in the account.
|
|
574
|
+
- Effect: Allow
|
|
575
|
+
Action:
|
|
576
|
+
- iam:PassRole
|
|
577
|
+
Resource: !GetAtt SaaSLayerCloudFormationExecutionRole.Arn
|
|
578
|
+
# Artifact staging: the bootstrap-created artifact bucket, the per-stack serverless
|
|
579
|
+
# deployment buckets (sl- prefixed), and the module data buckets named from the
|
|
580
|
+
# deployer slug (sldep*) — e.g. user-service's versioned cognito-user-backup bucket,
|
|
581
|
+
# which teardown must empty (ListBucketVersions/DeleteObjectVersion) before the stack
|
|
582
|
+
# can delete it, or destroy fails with AccessDenied on s3:ListBucketVersions.
|
|
583
|
+
- Effect: Allow
|
|
584
|
+
Action:
|
|
585
|
+
- s3:GetBucketLocation
|
|
586
|
+
- s3:GetObject
|
|
587
|
+
- s3:PutObject
|
|
588
|
+
- s3:PutObjectAcl
|
|
589
|
+
- s3:DeleteObject
|
|
590
|
+
- s3:DeleteObjectVersion
|
|
591
|
+
- s3:ListBucket
|
|
592
|
+
- s3:ListBucketVersions
|
|
593
|
+
Resource:
|
|
594
|
+
- !GetAtt DeploymentArtifactBucket.Arn
|
|
595
|
+
- !Sub ${DeploymentArtifactBucket.Arn}/*
|
|
596
|
+
- arn:aws:s3:::sl-*serverlessdeploymentbuck*
|
|
597
|
+
- arn:aws:s3:::sl-*serverlessdeploymentbuck*/*
|
|
598
|
+
- arn:aws:s3:::sldep*-cognito-user-backup-*
|
|
599
|
+
- arn:aws:s3:::sldep*-cognito-user-backup-*/*
|
|
600
|
+
# rbac-admin-ui static-site bucket: serverless-s3-sync uploads the SPA + config.json
|
|
601
|
+
# under this role at deploy, and teardown empties it before the stack deletes it.
|
|
602
|
+
- arn:aws:s3:::sl-*-adminui-*
|
|
603
|
+
- arn:aws:s3:::sl-*-adminui-*/*
|
|
604
|
+
# email-inbound-service raw-MIME + attachment buckets: SES writes inbound mail here
|
|
605
|
+
# and teardown must empty them (ListBucketVersions/DeleteObjectVersion) before the
|
|
606
|
+
# stack can delete them, or destroy fails with AccessDenied.
|
|
607
|
+
- arn:aws:s3:::sl-*-email-inbound-raw-*
|
|
608
|
+
- arn:aws:s3:::sl-*-email-inbound-raw-*/*
|
|
609
|
+
- arn:aws:s3:::sl-*-email-inbound-attachments-*
|
|
610
|
+
- arn:aws:s3:::sl-*-email-inbound-attachments-*/*
|
|
611
|
+
# Deploy tooling introspection after stack operations complete: stack enumeration
|
|
612
|
+
# (ListStacks has no resource scoping), API Gateway lifecycle calls the Serverless
|
|
613
|
+
# tooling makes outside CloudFormation, and lambda version/alias inspection.
|
|
614
|
+
- Effect: Allow
|
|
615
|
+
Action:
|
|
616
|
+
- cloudformation:ListStacks
|
|
617
|
+
- cloudformation:ListStackResources
|
|
618
|
+
- apigateway:DELETE
|
|
619
|
+
- apigateway:GET
|
|
620
|
+
- apigateway:PATCH
|
|
621
|
+
- apigateway:POST
|
|
622
|
+
- apigateway:PUT
|
|
623
|
+
- lambda:GetAlias
|
|
624
|
+
- lambda:GetFunction
|
|
625
|
+
- lambda:GetFunctionConfiguration
|
|
626
|
+
- lambda:ListAliases
|
|
627
|
+
- lambda:ListTags
|
|
628
|
+
- lambda:ListVersionsByFunction
|
|
629
|
+
Resource: '*'
|
|
630
|
+
# Post-deploy SEED data-plane: after a module deploys, the deployer runs its seed
|
|
631
|
+
# script under this role to make the deployment usable — create the initial admin
|
|
632
|
+
# user in the just-created Cognito pool (user-service seed) and bootstrap the tenant,
|
|
633
|
+
# admin role, and trust policy in the rbac tables (rbac-core seed). Cognito admin
|
|
634
|
+
# actions cannot be resource-scoped to a pool that does not exist at bootstrap time;
|
|
635
|
+
# DynamoDB is scoped to the rbac-* managed tables.
|
|
636
|
+
- Effect: Allow
|
|
637
|
+
Action:
|
|
638
|
+
- cognito-idp:AdminCreateUser
|
|
639
|
+
- cognito-idp:AdminGetUser
|
|
640
|
+
- cognito-idp:AdminSetUserPassword
|
|
641
|
+
- cognito-idp:ListUsers
|
|
642
|
+
Resource: !Sub arn:aws:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/*
|
|
643
|
+
- Effect: Allow
|
|
644
|
+
Action:
|
|
645
|
+
- dynamodb:GetItem
|
|
646
|
+
- dynamodb:PutItem
|
|
647
|
+
- dynamodb:UpdateItem
|
|
648
|
+
- dynamodb:Query
|
|
649
|
+
- dynamodb:BatchWriteItem
|
|
650
|
+
Resource:
|
|
651
|
+
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/rbac-*
|
|
652
|
+
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/rbac-*/index/*
|
|
653
|
+
|
|
654
|
+
# Cross-account READ-ONLY role for SaaSLayer support staff to diagnose managed deployments
|
|
655
|
+
# without the deployment role's write power. Trust matches the deployment role (control-plane
|
|
656
|
+
# account + external ID) and additionally pins the session name to saaslayer-support-* so each
|
|
657
|
+
# assumption is attributable in CloudTrail. Grants carry only Get/List/Describe verbs — enforced
|
|
658
|
+
# by tests/bootstrap.test.js — and exclude all data-plane reads: no S3 object reads, no DynamoDB
|
|
659
|
+
# item reads, no SSM parameter values, no Secrets Manager secret values.
|
|
660
|
+
SaaSLayerSupportReadOnlyRole:
|
|
661
|
+
Type: AWS::IAM::Role
|
|
662
|
+
Properties:
|
|
663
|
+
RoleName: SaaSLayerSupportReadOnlyRole
|
|
664
|
+
AssumeRolePolicyDocument:
|
|
665
|
+
Version: '2012-10-17'
|
|
666
|
+
Statement:
|
|
667
|
+
- Effect: Allow
|
|
668
|
+
Principal:
|
|
669
|
+
AWS: !Sub arn:aws:iam::${ControlPlaneAccountId}:root
|
|
670
|
+
Action: sts:AssumeRole
|
|
671
|
+
Condition:
|
|
672
|
+
StringEquals:
|
|
673
|
+
sts:ExternalId: !Ref ExternalId
|
|
674
|
+
StringLike:
|
|
675
|
+
sts:RoleSessionName: saaslayer-support-*
|
|
676
|
+
Policies:
|
|
677
|
+
- PolicyName: saaslayer-support-read-only
|
|
678
|
+
PolicyDocument:
|
|
679
|
+
Version: '2012-10-17'
|
|
680
|
+
Statement:
|
|
681
|
+
# Stack state, events, resources, and outputs for SaaSLayer-managed stacks only.
|
|
682
|
+
- Effect: Allow
|
|
683
|
+
Action:
|
|
684
|
+
- cloudformation:Describe*
|
|
685
|
+
- cloudformation:Get*
|
|
686
|
+
- cloudformation:ListStackResources
|
|
687
|
+
Resource: !Sub arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackNamePrefix}*
|
|
688
|
+
# Stack enumeration; the ListStacks API does not support resource scoping.
|
|
689
|
+
- Effect: Allow
|
|
690
|
+
Action:
|
|
691
|
+
- cloudformation:ListStacks
|
|
692
|
+
Resource: '*'
|
|
693
|
+
# Configuration reads scoped by resource tag: these services support the
|
|
694
|
+
# aws:ResourceTag condition key, and every SaaSLayer-deployed resource carries
|
|
695
|
+
# managed-by=saaslayer-deployer via stack tags. Untagged (customer) resources
|
|
696
|
+
# fail the condition and are not readable.
|
|
697
|
+
- Effect: Allow
|
|
698
|
+
Action:
|
|
699
|
+
- apigateway:GET
|
|
700
|
+
- cognito-idp:DescribeUserPool
|
|
701
|
+
- cognito-idp:DescribeUserPoolClient
|
|
702
|
+
- cognito-idp:GetUserPoolMfaConfig
|
|
703
|
+
- dynamodb:DescribeContinuousBackups
|
|
704
|
+
- dynamodb:DescribeTable
|
|
705
|
+
- dynamodb:DescribeTimeToLive
|
|
706
|
+
- dynamodb:ListTagsOfResource
|
|
707
|
+
- events:DescribeEventBus
|
|
708
|
+
- events:ListTagsForResource
|
|
709
|
+
- lambda:GetAlias
|
|
710
|
+
- lambda:GetFunction
|
|
711
|
+
- lambda:GetFunctionConfiguration
|
|
712
|
+
- lambda:GetFunctionEventInvokeConfig
|
|
713
|
+
- lambda:GetPolicy
|
|
714
|
+
- lambda:ListAliases
|
|
715
|
+
- lambda:ListTags
|
|
716
|
+
- lambda:ListVersionsByFunction
|
|
717
|
+
- sqs:GetQueueAttributes
|
|
718
|
+
- sqs:ListQueueTags
|
|
719
|
+
Resource: '*'
|
|
720
|
+
Condition:
|
|
721
|
+
StringEquals:
|
|
722
|
+
aws:ResourceTag/managed-by: saaslayer-deployer
|
|
723
|
+
# Log reads for diagnosing module function failures. CloudWatch Logs does not
|
|
724
|
+
# support aws:ResourceTag conditions on these read actions, and module log group
|
|
725
|
+
# names follow function names rather than a common prefix, so these cannot be
|
|
726
|
+
# tag- or ARN-scoped yet. They expose log content and log-group metadata only —
|
|
727
|
+
# no service configuration or data-plane records.
|
|
728
|
+
- Effect: Allow
|
|
729
|
+
Action:
|
|
730
|
+
- logs:DescribeLogGroups
|
|
731
|
+
- logs:DescribeLogStreams
|
|
732
|
+
- logs:GetLogEvents
|
|
733
|
+
- logs:GetLogGroupFields
|
|
734
|
+
- logs:GetLogRecord
|
|
735
|
+
- logs:ListTagsForResource
|
|
736
|
+
Resource: '*'
|
|
737
|
+
# Alarm/dashboard state for module observability. CloudWatch alarms support
|
|
738
|
+
# aws:ResourceTag; DescribeAlarms is an enumeration API evaluated per-alarm.
|
|
739
|
+
- Effect: Allow
|
|
740
|
+
Action:
|
|
741
|
+
- cloudwatch:DescribeAlarms
|
|
742
|
+
- cloudwatch:GetDashboard
|
|
743
|
+
- cloudwatch:ListDashboards
|
|
744
|
+
Resource: '*'
|
|
745
|
+
|
|
746
|
+
Outputs:
|
|
747
|
+
DeploymentRoleArn:
|
|
748
|
+
Description: Cross-account deployment role the SaaSLayer control plane assumes (external ID required).
|
|
749
|
+
Value: !GetAtt SaaSLayerDeploymentRole.Arn
|
|
750
|
+
SupportReadOnlyRoleArn:
|
|
751
|
+
Description: Cross-account read-only role SaaSLayer support staff assume for diagnostics (external ID required).
|
|
752
|
+
Value: !GetAtt SaaSLayerSupportReadOnlyRole.Arn
|
|
753
|
+
CloudFormationExecutionRoleArn:
|
|
754
|
+
Description: Service role CloudFormation uses to provision approved SaaSLayer module stacks; not assumable cross-account.
|
|
755
|
+
Value: !GetAtt SaaSLayerCloudFormationExecutionRole.Arn
|
|
756
|
+
DeploymentArtifactBucketName:
|
|
757
|
+
Description: Private, encrypted bucket holding packaged SaaSLayer deployment artifacts.
|
|
758
|
+
Value: !Ref DeploymentArtifactBucket
|
|
759
|
+
ManagedResourceBoundaryArn:
|
|
760
|
+
Description: Permissions boundary capping the runtime permissions of every IAM role created by SaaSLayer module stacks.
|
|
761
|
+
Value: !Ref SaaSLayerManagedResourceBoundary
|