saaslayer 0.4.0 → 0.4.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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # saaslayer
2
2
 
3
- SaaSLayer onboarding CLI. Bootstrap an AWS account for the SaaSLayer control plane and register a service's permissions manifest.
3
+ Manage SaaSLayer projects and deployments, connect your AWS account, and administer
4
+ your app's users and permissions. `saaslayer` is the customer CLI; the separate
5
+ `cplane` CLI is for SaaSLayer operators.
4
6
 
5
7
  ## Install
6
8
 
@@ -14,7 +16,97 @@ Or run without installing:
14
16
  npx saaslayer --help
15
17
  ```
16
18
 
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.
19
+ Requires Node.js >= 18. AWS connection and foundation commands also need the
20
+ [AWS CLI](https://aws.amazon.com/cli/) installed and credentials for the account
21
+ you intend to connect. Ordinary management commands use your SaaSLayer login.
22
+
23
+ ## First deployment
24
+
25
+ The documented beta path deploys into your AWS account. You need beta admission,
26
+ an accessible email address and permission to create the foundation in that
27
+ account. These commands create resources that can incur AWS charges.
28
+
29
+ ```bash
30
+ saaslayer signup
31
+ saaslayer login
32
+ saaslayer org create "Acme"
33
+ saaslayer project create "Acme app" --slug acme-app
34
+ saaslayer context
35
+ ```
36
+
37
+ Creating an organization and project selects each one locally. If they already
38
+ exist, use `saaslayer org list`, `saaslayer org use ORG_ID`, `saaslayer projects`
39
+ and `saaslayer project use PROJECT_ID` instead. Check `saaslayer context` before
40
+ connecting an AWS account or deploying.
41
+
42
+ With AWS credentials for the intended account, replace the account ID and
43
+ administrator email below. [Prepare your AWS account](https://saaslayer.com/docs/getting-started/aws-account-setup/)
44
+ covers a new AWS account, AWS CloudShell, and the least-privilege `SaaSLayerBootstrap`
45
+ policies in [`templates/bootstrap/`](templates/bootstrap/). Pass `--profile` to
46
+ pick an AWS CLI profile; without it the AWS CLI's default credentials are used.
47
+
48
+ ```bash
49
+ saaslayer aws connect --aws-account YOUR_AWS_ACCOUNT_ID --region us-east-1 --profile saaslayer-bootstrap
50
+ saaslayer stacks
51
+ saaslayer deploy --services user-service,permissions-service --hosting byoa --env dev --region us-east-1 --admin-email admin@example.com
52
+ saaslayer status --env dev --region us-east-1
53
+ ```
54
+
55
+ `--hosting byoa` explicitly selects your connected account. Without a hosting flag,
56
+ the control plane uses a connected project account when present and otherwise
57
+ selects hosted placement; use an explicit choice for this cloud-prem walkthrough.
58
+ `saaslayer stacks` reports the catalog module IDs and dependencies available to
59
+ your account. Review the CLI's creation/settings and cost confirmation prompts;
60
+ this example does not promise admission for every module or region.
61
+
62
+ Follow the deployment's first-admin sign-in instructions, then sign in to that
63
+ **deployment** when administering its users:
64
+
65
+ ```bash
66
+ saaslayer login --deployment dev
67
+ ```
68
+
69
+ The management login from `saaslayer login` and the deployment login are separate.
70
+ See [your first setup](https://saaslayer.com/docs/getting-started/first-customer-instance/)
71
+ and [Users](https://saaslayer.com/docs/users/quickstart/) for the next steps.
72
+
73
+ ## Command map
74
+
75
+ `saaslayer --help` is the complete command and flag reference. This README expands
76
+ selected workflows rather than duplicating every help entry.
77
+
78
+ | Task | Commands |
79
+ | --- | --- |
80
+ | Select the account, organization and project | `login`, `whoami`, `context`, `org`, `projects`, `project use` |
81
+ | Connect your AWS account | `aws connect`, `foundation status`, `foundation upgrade` |
82
+ | Inspect modules and releases | `stacks`, `versions` |
83
+ | Manage a deployment | `deploy`, `status`, `update`, `destroy` |
84
+ | Configure services | `settings`, `social`, `first-admin` |
85
+ | Administer app identities and access | `users`, `permissions`, `audit` |
86
+
87
+ ## Configuration and credentials
88
+
89
+ The control-plane API defaults to `https://api.saaslayer.com`. Override it with
90
+ `--config-url URL` or `SAASLAYER_CONFIG_URL` (the flag wins). A deployment's API
91
+ base is a different address: commands that call it use the deployment's published
92
+ outputs or an explicit `--api-base` as documented below.
93
+
94
+ The CLI keeps credentials in `~/.saaslayer/credentials.json` and selection context
95
+ in `~/.saaslayer/context.json`. `SAASLAYER_HOME` selects a different directory,
96
+ useful for an isolated environment. Keep that directory private: the credential
97
+ store includes session and refresh tokens. `--profile` selects AWS credentials
98
+ for commands that use AWS; it does not select a SaaSLayer login.
99
+
100
+ ## Troubleshooting
101
+
102
+ | Symptom | Check |
103
+ | --- | --- |
104
+ | Signup is refused | Confirm your email has beta admission before retrying; creating AWS resources does not grant admission. |
105
+ | `no project selected` | Run `saaslayer projects` in the intended org, then `saaslayer project use PROJECT_ID`, or pass `--project`. |
106
+ | Status is empty or shows another environment | Inspect `saaslayer context`; use the intended `--project`, `--env` and `--region`. |
107
+ | AWS connect reports credentials for another account | Select the intended AWS credentials, or use `--profile`, and rerun the connection command. |
108
+ | A users/permissions command lacks credentials or returns 403 | Use the deployment login or an explicitly authorized machine/API key. A control-plane login is not a deployment administrator credential. |
109
+ | A protected settings update asks for a reason | Supply `--reason` for staging/prod; follow the command's refusal details rather than changing managed stacks directly. |
18
110
 
19
111
  ## Commands
20
112
 
package/bin/saaslayer.js CHANGED
@@ -280,9 +280,19 @@ Usage:
280
280
  audit:person:erase. Prints { personId, status, emails: <count> } (addresses are never printed);
281
281
  status requested is finished by the deployment's audit worker within minutes. Safe to run again, with more addresses.
282
282
 
283
+ Organizations and projects (requires login):
284
+ saaslayer org create <name> Create an org (you are its owner) and make it the active org.
285
+ saaslayer org list List the orgs you belong to.
286
+ saaslayer org use <id> Set the active org.
287
+ saaslayer projects [--org ID] List the active org's projects.
288
+ saaslayer project create <name> [--slug <slug>] [--org ID]
289
+ Create a project in the active org and make it the active project. --slug is its public deploy name (letter-first,
290
+ lowercase, at most 15 characters; derived from the name when omitted).
291
+
283
292
  Deploy & lifecycle (requires login + a connected AWS account):
284
- saaslayer aws connect --aws-account <id> [--region R] [--org ID] [--org-wide] [--sms-toll-free [--yes]]
285
- Connect your AWS account to an org. Binds it to your active project by
293
+ saaslayer aws connect --aws-account <id> [--region R] [--profile P] [--org ID] [--org-wide] [--sms-toll-free [--yes]]
294
+ Connect your AWS account to an org, with YOUR AWS credentials for that account (--profile, else the AWS CLI's
295
+ default credentials: environment, SSO profile or AWS CloudShell). Binds it to your active project by
286
296
  default; --org-wide lets any project in the org deploy into it. The account foundation lives in one home region
287
297
  (created by the first connect); connecting another region adds only that region's stack. --sms-toll-free also installs the account's US
288
298
  toll-free SMS sending number (~$2/month, asks first unless --yes) and prints its ARN.
@@ -339,8 +349,10 @@ Deploy & lifecycle (requires login + a connected AWS account):
339
349
  The versions a deployment may move to, highest first: the channels on each (stable), breaking releases, and
340
350
  which of the project's deployments run each one (a deployment on an unversioned commit is listed apart).
341
351
  saaslayer deploy [--services a,b | --module M ...] [--set MODULE.Setting=VALUE ...] [--settings FILE] [--env prod]
342
- [--region R] [--target ACCT] [--version X.Y.Z | --channel stable] [--admin-email E | --admin-phone-number +E164] [--yes]
343
- Deploy the project's modules into your connected account. --services/--module and --set take catalog module
352
+ [--region R] [--hosting hosted|byoa] [--target ACCT] [--version X.Y.Z | --channel stable] [--admin-email E | --admin-phone-number +E164] [--yes]
353
+ Deploy the project's modules. --hosting hosted runs them in a SaaSLayer AWS account (no AWS account of your own);
354
+ --hosting byoa runs them in your connected account (\`saaslayer aws connect\`). Without it, a project with a
355
+ connected account deploys there and one without is hosted. --services/--module and --set take catalog module
344
356
  ids (\`saaslayer stacks\`, e.g. permissions-service); an unknown id or a missing required module is refused before
345
357
  anything is sent. --settings FILE is { "<module>": { "<Setting>": value } }; --set overrides it (--param is
346
358
  the same as --set). --version (\`saaslayer versions\`) or --channel names the release to start on; without either
@@ -465,9 +477,9 @@ Deploy & lifecycle (requires login + a connected AWS account):
465
477
  saaslayer login-domain activate --confirm-domain HOST --reason TEXT [--env E] [--service REF] [--no-wait] [--json]
466
478
  saaslayer login-domain deactivate --confirm-domain HOST --reason TEXT [--env E] [--service REF] [--no-wait] [--json]
467
479
  Advertise the custom login domain (activate) or the opaque one again (deactivate). Switching breaks the provider
468
- redirects, app callbacks and passkeys registered against the current host, so it is refused
469
- (LOGIN_DOMAIN_HANDOFF_REQUIRED, listing them) unless --confirm-domain names the current host; the issuer does
470
- not change. A completion checklist is printed: the switch is done when the new host serves sign-in and every
480
+ redirects and app callbacks registered against the current host, so it is refused
481
+ (LOGIN_DOMAIN_HANDOFF_REQUIRED, listing them) unless --confirm-domain names the current host; passkeys and the
482
+ issuer do not change. A completion checklist is printed: the switch is done when the new host serves sign-in and every
471
483
  listed redirect and callback is updated. Register the new redirect URI before activate and keep the old one.
472
484
  saaslayer login-domain remove [--env E] [--service REF] [--reason TEXT] [--no-wait] [--json]
473
485
  Delete the custom login domain, its DNS alias and (for HOST) its certificate, and free its quota slot. Refused
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saaslayer",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "SaaSLayer CLI — onboard an account (init) and register a service's permissions manifest.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "scripts": {
44
- "test": "node scripts/sync-template.js --check && node scripts/sync-vendor.js --check && node bin/saaslayer.js --help >/dev/null && node test/credentials.test.js && node test/multi-account.test.js && node test/aws.test.js && node test/api-client-refresh.test.js && node test/update.test.js && node test/versions.test.js && node test/migrations-approve.test.js && node test/service-add.test.js && node test/service-remove.test.js && node test/destroy.test.js && node test/settings.test.js && node test/login-methods.test.js && node test/settings-login-domain.test.js && node test/login-domain.test.js && node test/env-compare.test.js && node test/release-manifest.test.js && node test/operations.test.js && node test/projects.test.js && node test/activity.test.js && node test/integration-credentials.test.js && node test/users-management.test.js && node test/deploy.test.js && node test/module-catalog.test.js && node test/stacks.test.js && node test/catalog.test.js && node test/catalog-registry.test.js && node test/permissions-inspect.test.js && node test/permissions-commands.test.js && node test/iam.test.js && node test/machine-trust.test.js && node test/access-admins.test.js && node test/support-staff.test.js && node test/permission-orgs.test.js && node test/first-admin.test.js && node test/social.test.js && node test/hooks.test.js && node test/service-principals.test.js && node test/package-files.test.js && node test/users-export.test.js && node test/users-import.test.js && node test/users-import-checkpoint.test.js && node test/users-import-profiles.test.js && node test/users.test.js && node test/users-api.test.js && node test/migrate.test.js && node test/foundation-template.test.js && node test/trust-entries.test.js && node test/foundation-home.test.js && node test/foundation.test.js && node test/foundation-change-set.test.js && node test/foundation-trust-write.test.js && node test/connection-proof.test.js && node test/aws-connect.test.js && node test/aws-rotate-trust.test.js && node test/sms-setup.test.js && node test/sms-release.test.js && node test/scope.test.js && node test/discovery.test.js && node test/credential-profiles.test.js && node test/login-challenges.test.js && node test/login-prompt.test.js && node test/control-plane-url.test.js && node test/signup.test.js && node test/org-members.test.js && node test/sms-register.test.js && node test/sms-status.test.js && echo ok && node test/id-token-auth.test.js && node test/trust-policies.test.js && node test/api-keys.test.js && node test/bindings.test.js && node test/binding-handoff.test.js && node test/env-export.test.js && node test/audit-erase.test.js",
44
+ "test": "node scripts/sync-template.js --check && node scripts/sync-vendor.js --check && node bin/saaslayer.js --help >/dev/null && node test/credentials.test.js && node test/multi-account.test.js && node test/aws.test.js && node test/api-client-refresh.test.js && node test/update.test.js && node test/versions.test.js && node test/migrations-approve.test.js && node test/service-add.test.js && node test/service-remove.test.js && node test/destroy.test.js && node test/settings.test.js && node test/login-methods.test.js && node test/settings-login-domain.test.js && node test/login-domain.test.js && node test/env-compare.test.js && node test/release-manifest.test.js && node test/operations.test.js && node test/projects.test.js && node test/activity.test.js && node test/integration-credentials.test.js && node test/users-management.test.js && node test/deploy.test.js && node test/module-catalog.test.js && node test/stacks.test.js && node test/catalog.test.js && node test/catalog-registry.test.js && node test/permissions-inspect.test.js && node test/permissions-commands.test.js && node test/iam.test.js && node test/machine-trust.test.js && node test/access-admins.test.js && node test/support-staff.test.js && node test/permission-orgs.test.js && node test/first-admin.test.js && node test/social.test.js && node test/hooks.test.js && node test/service-principals.test.js && node test/package-files.test.js && node test/users-export.test.js && node test/users-import.test.js && node test/users-import-checkpoint.test.js && node test/users-import-profiles.test.js && node test/users.test.js && node test/users-api.test.js && node test/migrate.test.js && node test/foundation-template.test.js && node test/trust-entries.test.js && node test/foundation-home.test.js && node test/foundation.test.js && node test/foundation-change-set.test.js && node test/foundation-trust-write.test.js && node test/connection-proof.test.js && node test/aws-connect.test.js && node test/bootstrap-policy.test.js && node test/aws-rotate-trust.test.js && node test/sms-setup.test.js && node test/sms-release.test.js && node test/scope.test.js && node test/discovery.test.js && node test/credential-profiles.test.js && node test/login-challenges.test.js && node test/login-prompt.test.js && node test/control-plane-url.test.js && node test/signup.test.js && node test/org-members.test.js && node test/sms-register.test.js && node test/sms-status.test.js && echo ok && node test/id-token-auth.test.js && node test/trust-policies.test.js && node test/api-keys.test.js && node test/bindings.test.js && node test/binding-handoff.test.js && node test/env-export.test.js && node test/audit-erase.test.js",
45
45
  "sync-template": "node scripts/sync-template.js",
46
46
  "sync-template:check": "node scripts/sync-template.js --check",
47
47
  "prepublishOnly": "node scripts/sync-template.js",
@@ -1,4 +1,4 @@
1
- // `saaslayer deploy` (swf2.7) — self-serve deploy of the customer's project into their connected account.
1
+ // `saaslayer deploy` (swf2.7) — self-serve deploy of the customer's project into a SaaSLayer pool account or their connected account.
2
2
  // POSTs to the BFF (Bearer id token); the BFF authorizes the caller, resolves the target, and calls the
3
3
  // deployer. Handles the two-step cost-confirm (D14): the first call returns NEEDS_CONFIRMATION with an
4
4
  // estimate; on y (or --yes) we re-send confirmCost:true. Then waits for the deploy operation unless --no-wait.
@@ -24,6 +24,19 @@ function selectedModules(flags) {
24
24
  return ids.length ? ids : undefined
25
25
  }
26
26
 
27
+ /**
28
+ * Where the deploy runs from --hosting: hosted (a SaaSLayer pool account) or byoa (your connected AWS account); absent,
29
+ * the control plane uses the project's connected account when there is one, else hosts it.
30
+ * @param {Record<string, any>} flags
31
+ * @returns {'hosted'|'byoa'|undefined}
32
+ */
33
+ function hostingChoice(flags) {
34
+ if (flags.hosting === undefined) return undefined
35
+ if (flags.hosting !== 'hosted' && flags.hosting !== 'byoa') throw new Error('--hosting must be hosted (a SaaSLayer pool account) or byoa (your connected AWS account)')
36
+ if (flags.hosting === 'hosted' && flags.target) throw new Error('--target names your own account: drop it, or use --hosting byoa')
37
+ return flags.hosting
38
+ }
39
+
27
40
  /**
28
41
  * Check create settings against each module's schema at the revision being deployed (--commit-sha, else the default
29
42
  * release the catalog reports) and name the create-only ones. A --version or --channel names no commit here (versions
@@ -61,6 +74,7 @@ async function deploy(flags, io = {}) {
61
74
  const interactive = io.interactive === undefined ? Boolean(process.stdin.isTTY) : io.interactive
62
75
  const ask = io.confirm || confirm
63
76
  const yes = flags.yes === true || flags.yes === 'true'
77
+ const hosting = hostingChoice(flags)
64
78
  const scope = resolveScope(flags, { env: 'prod' })
65
79
  printScope(scope, flags)
66
80
  const project = scope.project.value
@@ -95,6 +109,7 @@ async function deploy(flags, io = {}) {
95
109
  ...(services ? { services } : {}),
96
110
  ...(flags.region ? { region: flags.region } : {}),
97
111
  ...(flags.target ? { targetAccountId: flags.target } : {}),
112
+ ...(hosting ? { hosting } : {}),
98
113
  ...(choice || {}),
99
114
  ...(flags['admin-email'] ? { adminEmail: flags['admin-email'] } : {}),
100
115
  ...(adminPhoneNumber ? { adminPhoneNumber } : {}),
@@ -4,6 +4,9 @@
4
4
  const { apiCall } = require('./api-client')
5
5
  const { resolveScope, printScope, deployedProjectsHint } = require('./scope')
6
6
 
7
+ // Deployment statuses that hold no running stacks a command could act on alongside a live deployment.
8
+ const DEAD_STATUSES = new Set(['CREATE_FAILED', 'DESTROYED', 'PURGE_PENDING', 'PURGE_IN_PROGRESS', 'PURGE_FAILED', 'RETIRED'])
9
+
7
10
  async function resolveDeployment(flags) {
8
11
  const scope = resolveScope(flags, { env: 'prod' })
9
12
  printScope(scope, flags)
@@ -14,11 +17,20 @@ async function resolveDeployment(flags) {
14
17
  const group = (view.environments || []).find((g) => g.environment === env)
15
18
  let instances = group ? group.instances : []
16
19
  if (region) instances = instances.filter((i) => i.region === region)
20
+ const selected = typeof flags.deployment === 'string' && flags.deployment.startsWith('dep_') ? flags.deployment : null
21
+ if (selected) instances = instances.filter((i) => i.deploymentId === selected)
22
+ // A failed or destroyed deployment never shadows a live one in the same env; alone, it still resolves (status, destroy).
23
+ const live = instances.filter((i) => !DEAD_STATUSES.has(i.status))
24
+ if (live.length && live.length < instances.length) instances = live
17
25
  if (instances.length === 0) {
18
26
  const hint = await deployedProjectsHint(scope, flags)
19
27
  throw new Error([`no ${env} deployment${region ? ` in ${region}` : ''} for project ${project} (${scope.project.kind})`, ...hint].join('\n'))
20
28
  }
21
- if (instances.length > 1) throw new Error(`multiple ${env} deployments — pass --region <r>: ${instances.map((i) => i.region).join(', ')}`)
29
+ if (instances.length > 1) {
30
+ const regions = new Set(instances.map((i) => i.region))
31
+ if (regions.size < instances.length) throw new Error(`multiple ${env} deployments in ${[...regions].join(', ')} — pass --deployment <id>: ${instances.map((i) => i.deploymentId).join(', ')}`)
32
+ throw new Error(`multiple ${env} deployments — pass --region <r>: ${instances.map((i) => i.region).join(', ')}`)
33
+ }
22
34
  const inst = instances[0]
23
35
  return { project, env, region: inst.region, deploymentId: inst.deploymentId, status: inst.status, commitSha: inst.commitSha || null, version: inst.version || null }
24
36
  }
@@ -51,7 +51,6 @@ function refusalError(refused, breaks, oldHost) {
51
51
  const lines = [
52
52
  ...breaks.providerRedirects.map(({ provider, redirectUri }) => ` - ${provider} redirect URI ${redirectUri}`),
53
53
  ...breaks.appCallbacks.map((url) => ` - app callback ${url}`),
54
- ...breaks.passkeyRelyingParties.map((rp) => ` - passkeys for relying party ${rp}`),
55
54
  ` - apps built with SAASLAYER_HOSTED_LOGIN_URL=https://${host} (saaslayer env export) need a rebuild`,
56
55
  ` - hosted-UI sessions on ${host} sign in once more`,
57
56
  ' - the issuer does not change',
@@ -0,0 +1,148 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "FoundationStacks",
6
+ "Effect": "Allow",
7
+ "Action": [
8
+ "cloudformation:CreateStack",
9
+ "cloudformation:DeleteStack",
10
+ "cloudformation:DescribeStacks",
11
+ "cloudformation:DescribeStackEvents",
12
+ "cloudformation:GetTemplate",
13
+ "cloudformation:CreateChangeSet",
14
+ "cloudformation:DescribeChangeSet",
15
+ "cloudformation:ExecuteChangeSet",
16
+ "cloudformation:DeleteChangeSet",
17
+ "cloudformation:ContinueUpdateRollback"
18
+ ],
19
+ "Resource": [
20
+ "arn:aws:cloudformation:*:*:stack/saaslayer-foundation*/*",
21
+ "arn:aws:cloudformation:*:*:changeSet/saaslayer-*/*"
22
+ ]
23
+ },
24
+ {
25
+ "Sid": "FindStacks",
26
+ "Effect": "Allow",
27
+ "Action": [
28
+ "cloudformation:ListStacks",
29
+ "cloudformation:DescribeStackResources"
30
+ ],
31
+ "Resource": "*"
32
+ },
33
+ {
34
+ "Sid": "FoundationRoles",
35
+ "Effect": "Allow",
36
+ "Action": [
37
+ "iam:CreateRole",
38
+ "iam:DeleteRole",
39
+ "iam:GetRole",
40
+ "iam:UpdateRole",
41
+ "iam:UpdateRoleDescription",
42
+ "iam:UpdateAssumeRolePolicy",
43
+ "iam:PutRolePolicy",
44
+ "iam:GetRolePolicy",
45
+ "iam:DeleteRolePolicy",
46
+ "iam:ListRolePolicies",
47
+ "iam:AttachRolePolicy",
48
+ "iam:DetachRolePolicy",
49
+ "iam:ListAttachedRolePolicies",
50
+ "iam:PutRolePermissionsBoundary",
51
+ "iam:DeleteRolePermissionsBoundary",
52
+ "iam:TagRole",
53
+ "iam:UntagRole",
54
+ "iam:ListRoleTags"
55
+ ],
56
+ "Resource": "arn:aws:iam::*:role/sl-foundation-*"
57
+ },
58
+ {
59
+ "Sid": "FoundationManagedPolicies",
60
+ "Effect": "Allow",
61
+ "Action": [
62
+ "iam:CreatePolicy",
63
+ "iam:DeletePolicy",
64
+ "iam:GetPolicy",
65
+ "iam:GetPolicyVersion",
66
+ "iam:ListPolicyVersions",
67
+ "iam:CreatePolicyVersion",
68
+ "iam:DeletePolicyVersion",
69
+ "iam:ListEntitiesForPolicy"
70
+ ],
71
+ "Resource": "arn:aws:iam::*:policy/sl-foundation-*"
72
+ },
73
+ {
74
+ "Sid": "FoundationParameter",
75
+ "Effect": "Allow",
76
+ "Action": [
77
+ "ssm:GetParameter",
78
+ "ssm:GetParameters",
79
+ "ssm:PutParameter",
80
+ "ssm:DeleteParameter",
81
+ "ssm:AddTagsToResource",
82
+ "ssm:RemoveTagsFromResource",
83
+ "ssm:ListTagsForResource"
84
+ ],
85
+ "Resource": "arn:aws:ssm:*:*:parameter/saaslayer/foundation/*"
86
+ },
87
+ {
88
+ "Sid": "ArtifactBuckets",
89
+ "Effect": "Allow",
90
+ "Action": [
91
+ "s3:CreateBucket",
92
+ "s3:DeleteBucket*",
93
+ "s3:Get*",
94
+ "s3:List*",
95
+ "s3:Put*",
96
+ "s3:TagResource",
97
+ "s3:UntagResource"
98
+ ],
99
+ "Resource": "arn:aws:s3:::sl-artifacts-*"
100
+ },
101
+ {
102
+ "Sid": "ArtifactBucketObjects",
103
+ "Effect": "Allow",
104
+ "Action": [
105
+ "s3:DeleteObject",
106
+ "s3:PutObjectAcl"
107
+ ],
108
+ "Resource": [
109
+ "arn:aws:s3:::sl-artifacts-*",
110
+ "arn:aws:s3:::sl-artifacts-*/*"
111
+ ]
112
+ },
113
+ {
114
+ "Sid": "EmailSenderDomain",
115
+ "Effect": "Allow",
116
+ "Action": [
117
+ "ses:CreateEmailIdentity",
118
+ "ses:DeleteEmailIdentity",
119
+ "ses:GetEmailIdentity",
120
+ "ses:PutEmailIdentityDkimAttributes",
121
+ "ses:PutEmailIdentityDkimSigningAttributes",
122
+ "ses:PutEmailIdentityFeedbackAttributes",
123
+ "ses:PutEmailIdentityMailFromAttributes",
124
+ "ses:TagResource",
125
+ "ses:UntagResource",
126
+ "ses:ListTagsForResource"
127
+ ],
128
+ "Resource": "arn:aws:ses:*:*:identity/*"
129
+ },
130
+ {
131
+ "Sid": "SmsSendingNumber",
132
+ "Effect": "Allow",
133
+ "Action": [
134
+ "sms-voice:RequestPhoneNumber",
135
+ "sms-voice:DescribePhoneNumbers",
136
+ "sms-voice:UpdatePhoneNumber",
137
+ "sms-voice:ReleasePhoneNumber",
138
+ "sms-voice:DescribeKeywords",
139
+ "sms-voice:PutKeyword",
140
+ "sms-voice:DeleteKeyword",
141
+ "sms-voice:TagResource",
142
+ "sms-voice:UntagResource",
143
+ "sms-voice:ListTagsForResource"
144
+ ],
145
+ "Resource": "*"
146
+ }
147
+ ]
148
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "EmailSenderDomain",
6
+ "Effect": "Allow",
7
+ "Action": [
8
+ "ses:CreateEmailIdentity",
9
+ "ses:DeleteEmailIdentity",
10
+ "ses:GetEmailIdentity",
11
+ "ses:PutEmailIdentityDkimAttributes",
12
+ "ses:PutEmailIdentityDkimSigningAttributes",
13
+ "ses:PutEmailIdentityFeedbackAttributes",
14
+ "ses:PutEmailIdentityMailFromAttributes",
15
+ "ses:TagResource",
16
+ "ses:UntagResource",
17
+ "ses:ListTagsForResource"
18
+ ],
19
+ "Resource": "arn:aws:ses:*:*:identity/*"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "SmsSendingNumber",
6
+ "Effect": "Allow",
7
+ "Action": [
8
+ "sms-voice:RequestPhoneNumber",
9
+ "sms-voice:DescribePhoneNumbers",
10
+ "sms-voice:UpdatePhoneNumber",
11
+ "sms-voice:ReleasePhoneNumber",
12
+ "sms-voice:DescribeKeywords",
13
+ "sms-voice:PutKeyword",
14
+ "sms-voice:DeleteKeyword",
15
+ "sms-voice:TagResource",
16
+ "sms-voice:UntagResource",
17
+ "sms-voice:ListTagsForResource"
18
+ ],
19
+ "Resource": "*"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "FoundationStacks",
6
+ "Effect": "Allow",
7
+ "Action": [
8
+ "cloudformation:CreateStack",
9
+ "cloudformation:DeleteStack",
10
+ "cloudformation:DescribeStacks",
11
+ "cloudformation:DescribeStackEvents",
12
+ "cloudformation:GetTemplate",
13
+ "cloudformation:CreateChangeSet",
14
+ "cloudformation:DescribeChangeSet",
15
+ "cloudformation:ExecuteChangeSet",
16
+ "cloudformation:DeleteChangeSet",
17
+ "cloudformation:ContinueUpdateRollback"
18
+ ],
19
+ "Resource": [
20
+ "arn:aws:cloudformation:*:*:stack/saaslayer-foundation*/*",
21
+ "arn:aws:cloudformation:*:*:changeSet/saaslayer-*/*"
22
+ ]
23
+ },
24
+ {
25
+ "Sid": "FindStacks",
26
+ "Effect": "Allow",
27
+ "Action": [
28
+ "cloudformation:ListStacks",
29
+ "cloudformation:DescribeStackResources"
30
+ ],
31
+ "Resource": "*"
32
+ },
33
+ {
34
+ "Sid": "FoundationRoles",
35
+ "Effect": "Allow",
36
+ "Action": [
37
+ "iam:CreateRole",
38
+ "iam:DeleteRole",
39
+ "iam:GetRole",
40
+ "iam:UpdateRole",
41
+ "iam:UpdateRoleDescription",
42
+ "iam:UpdateAssumeRolePolicy",
43
+ "iam:PutRolePolicy",
44
+ "iam:GetRolePolicy",
45
+ "iam:DeleteRolePolicy",
46
+ "iam:ListRolePolicies",
47
+ "iam:AttachRolePolicy",
48
+ "iam:DetachRolePolicy",
49
+ "iam:ListAttachedRolePolicies",
50
+ "iam:PutRolePermissionsBoundary",
51
+ "iam:DeleteRolePermissionsBoundary",
52
+ "iam:TagRole",
53
+ "iam:UntagRole",
54
+ "iam:ListRoleTags"
55
+ ],
56
+ "Resource": "arn:aws:iam::*:role/sl-foundation-*"
57
+ },
58
+ {
59
+ "Sid": "FoundationManagedPolicies",
60
+ "Effect": "Allow",
61
+ "Action": [
62
+ "iam:CreatePolicy",
63
+ "iam:DeletePolicy",
64
+ "iam:GetPolicy",
65
+ "iam:GetPolicyVersion",
66
+ "iam:ListPolicyVersions",
67
+ "iam:CreatePolicyVersion",
68
+ "iam:DeletePolicyVersion",
69
+ "iam:ListEntitiesForPolicy"
70
+ ],
71
+ "Resource": "arn:aws:iam::*:policy/sl-foundation-*"
72
+ },
73
+ {
74
+ "Sid": "FoundationParameter",
75
+ "Effect": "Allow",
76
+ "Action": [
77
+ "ssm:GetParameter",
78
+ "ssm:GetParameters",
79
+ "ssm:PutParameter",
80
+ "ssm:DeleteParameter",
81
+ "ssm:AddTagsToResource",
82
+ "ssm:RemoveTagsFromResource",
83
+ "ssm:ListTagsForResource"
84
+ ],
85
+ "Resource": "arn:aws:ssm:*:*:parameter/saaslayer/foundation/*"
86
+ },
87
+ {
88
+ "Sid": "ArtifactBuckets",
89
+ "Effect": "Allow",
90
+ "Action": [
91
+ "s3:CreateBucket",
92
+ "s3:DeleteBucket*",
93
+ "s3:Get*",
94
+ "s3:List*",
95
+ "s3:Put*",
96
+ "s3:TagResource",
97
+ "s3:UntagResource"
98
+ ],
99
+ "Resource": "arn:aws:s3:::sl-artifacts-*"
100
+ },
101
+ {
102
+ "Sid": "ArtifactBucketObjects",
103
+ "Effect": "Allow",
104
+ "Action": [
105
+ "s3:DeleteObject",
106
+ "s3:PutObjectAcl"
107
+ ],
108
+ "Resource": [
109
+ "arn:aws:s3:::sl-artifacts-*",
110
+ "arn:aws:s3:::sl-artifacts-*/*"
111
+ ]
112
+ }
113
+ ]
114
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Sid": "AdministratorsOfThisAccountWithMfa",
6
+ "Effect": "Allow",
7
+ "Principal": {
8
+ "AWS": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:root"
9
+ },
10
+ "Action": "sts:AssumeRole",
11
+ "Condition": {
12
+ "Bool": {
13
+ "aws:MultiFactorAuthPresent": "true"
14
+ }
15
+ }
16
+ }
17
+ ]
18
+ }
@@ -86,52 +86,38 @@ Parameters:
86
86
  Type: String
87
87
  AllowedPattern: '^[0-9]{12}$'
88
88
  Description: >-
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.
89
+ Initial control-plane AWS account ID (informational). TrustEntries determines each control plane's trust.
91
90
  TrustEntries:
92
91
  Type: String
93
92
  MaxLength: 4096
94
93
  Description: >-
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.
94
+ JSON v1 entries: controlPlaneId, principalAccountId, trustIdentifiers, deployCallerArns, supportCallerArns. The CLI renders trust; identifiers are ExternalIds, not secrets.
98
95
  ConnectionAuthorizerArns:
99
96
  Type: CommaDelimitedList
100
97
  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.
98
+ Path-less IAM principal ARNs allowed to authorize org connections. Defaults to the installer; changes require an explicit authorizer update.
104
99
  StackNamePrefix:
105
100
  Type: String
106
101
  Default: sl-
107
102
  Description: >-
108
- Prefix for SaaSLayer-managed CloudFormation stacks. The deployment role can only operate on
109
- stacks whose names start with this prefix.
103
+ The deployment role manages only CloudFormation stacks starting with this prefix.
110
104
  OrgId:
111
105
  Type: String
112
106
  Default: ''
113
107
  Description: >-
114
- SaaSLayer org this account is connected to. Informational only — never used in a policy or
115
- trust decision. Surfaced in Outputs so support can identify the account from the stack alone.
108
+ Connected SaaSLayer org (informational output only; never used for authorization).
116
109
  EnableEmailInbound:
117
110
  Type: String
118
111
  AllowedValues: ['true', 'false']
119
112
  Default: 'false'
120
113
  Description: >-
121
- When 'true', grant the SES receipt-rule provisioning + inbound-mail runtime permissions that
122
- email-inbound-service needs. Default 'false' so host accounts that do NOT run email-inbound are
123
- not over-permissioned for SES. Set per host via `cplane accounts enable-capability <host> ses`.
114
+ Inbound SES permissions for email-inbound-service. Enable only on inbound-mail hosts: cplane accounts enable-capability <host> ses.
124
115
  EnableTenantEdge:
125
116
  Type: String
126
117
  AllowedValues: ['true', 'false']
127
118
  Default: 'false'
128
119
  Description: >-
129
- When 'true', grant the CloudFront distribution + edge-Function permissions the NATIVE
130
- single-tenant edge (epic f55t, Model B) provisions in this account. Default 'false' so host
131
- accounts that route through the shared edge are not granted CloudFront write. Set per host via
132
- `cplane accounts enable-capability <host> tenant-edge`.
133
- WARNING (rollout order): a host ALREADY running the native edge must have this enabled BEFORE
134
- its foundation is redeployed at >= 1.1.0, or the redeploy strips the perms its live edge needs.
120
+ Native single-tenant edge CloudFront permissions. Enable: cplane accounts enable-capability <host> tenant-edge. Existing native-edge hosts must enable this before foundation >= 1.1.0 redeploy to preserve permissions.
135
121
 
136
122
  Conditions:
137
123
  # Capability gates. Each maps 1:1 to an entry in @saaslayer/foundation-contract (packages/
@@ -150,7 +136,7 @@ Mappings:
150
136
  # patch = comments/docs/no behavior change
151
137
  Meta:
152
138
  Foundation:
153
- Version: '8.0.0'
139
+ Version: '8.3.0'
154
140
 
155
141
  Resources:
156
142
  # The shared deployment-artifact bucket moved OUT of this account-global stack into the per-region
@@ -402,6 +388,16 @@ Resources:
402
388
  Condition:
403
389
  StringEquals:
404
390
  aws:RequestTag/managed-by: saaslayer-deployer
391
+ # GlobalTable's provider reads the AWS-managed DynamoDB key when SSEEnabled is true without a CMK.
392
+ # AWS-managed keys cannot carry our resource tag; allow metadata only, for this service alias only.
393
+ - Effect: Allow
394
+ Action:
395
+ - kms:DescribeKey
396
+ Resource: !Sub arn:${AWS::Partition}:kms:*:${AWS::AccountId}:key/*
397
+ Condition:
398
+ ForAnyValue:StringEquals:
399
+ kms:ResourceAliases:
400
+ - alias/aws/dynamodb
405
401
  # Grant + data-plane actions: a resource encrypted with a customer CMK (email-inbound's
406
402
  # InboundTable via DynamoDB SSE-KMS) makes the service create a grant AND
407
403
  # decrypt/generate data keys against the CMK during provisioning — without these the
@@ -951,6 +947,7 @@ Resources:
951
947
  ForAnyValue:StringNotEquals:
952
948
  cloudformation:ImportResourceTypes:
953
949
  - AWS::DynamoDB::Table
950
+ - AWS::DynamoDB::GlobalTable
954
951
  - AWS::Cognito::UserPool
955
952
  - AWS::Cognito::UserPoolClient
956
953
  - AWS::Cognito::UserPoolGroup
@@ -1106,6 +1103,8 @@ Resources:
1106
1103
  - dynamodb:DeleteItem
1107
1104
  - dynamodb:Query
1108
1105
  - dynamodb:BatchWriteItem
1106
+ # Audit transactions (permissions seed) carry ConditionCheck items on erasure markers.
1107
+ - dynamodb:ConditionCheckItem
1109
1108
  # Teardown cleanup: a table with DeletionPolicy:Retain survives `serverless remove`, so the
1110
1109
  # deployer's module-runner deletes those retained sl-* tables directly after the stack is gone
1111
1110
  # (deleteStackOwnedTables) — else a same-named recreate collides. Scoped to sl-* tables only.