saaslayer 0.3.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.
Files changed (65) hide show
  1. package/README.md +199 -18
  2. package/bin/saaslayer.js +335 -62
  3. package/package.json +3 -2
  4. package/src/aws-sigv4.js +74 -26
  5. package/src/commands/access-admins.js +2 -2
  6. package/src/commands/admin-allowlist.js +23 -3
  7. package/src/commands/api-keys.js +83 -0
  8. package/src/commands/audit.js +77 -0
  9. package/src/commands/aws.js +355 -82
  10. package/src/commands/binding-handoff.js +174 -0
  11. package/src/commands/bindings.js +111 -0
  12. package/src/commands/catalog.js +30 -3
  13. package/src/commands/deploy.js +49 -11
  14. package/src/commands/env-export.js +58 -0
  15. package/src/commands/first-admin.js +15 -4
  16. package/src/commands/foundation.js +75 -117
  17. package/src/commands/hooks.js +271 -0
  18. package/src/commands/integration-credentials.js +1 -1
  19. package/src/commands/lifecycle.js +149 -24
  20. package/src/commands/login-domain.js +259 -0
  21. package/src/commands/permission-orgs.js +80 -0
  22. package/src/commands/release-manifest.js +17 -8
  23. package/src/commands/service-principals.js +42 -5
  24. package/src/commands/settings.js +21 -5
  25. package/src/commands/sms-registration.js +182 -0
  26. package/src/commands/sms.js +178 -0
  27. package/src/commands/social.js +265 -0
  28. package/src/commands/support-staff.js +72 -0
  29. package/src/commands/users-management.js +2 -20
  30. package/src/commands/users.js +56 -11
  31. package/src/commands/versions.js +61 -0
  32. package/src/connection-proof.js +41 -0
  33. package/src/deployments.js +14 -2
  34. package/src/foundation-change-set.js +180 -0
  35. package/src/foundation-home.js +121 -0
  36. package/src/foundation-template.js +51 -10
  37. package/src/foundation-trust-write.js +379 -0
  38. package/src/iam-session.js +14 -8
  39. package/src/login-domain.js +138 -0
  40. package/src/login-methods.js +118 -0
  41. package/src/module-catalog.js +3 -2
  42. package/src/release-manifest.js +11 -4
  43. package/src/scope.js +3 -1
  44. package/src/settings.js +85 -13
  45. package/src/sms/number.js +37 -0
  46. package/src/sms/registration-fields.js +167 -0
  47. package/src/sms/registration-validate.js +151 -0
  48. package/src/sms/registration.js +216 -0
  49. package/src/sms/release.js +55 -0
  50. package/src/sms/scope.js +86 -0
  51. package/src/sms/status.js +181 -0
  52. package/src/ssm-api.js +31 -0
  53. package/src/trust-entries.js +350 -0
  54. package/src/user-service-instance.js +27 -0
  55. package/src/users-api.js +55 -8
  56. package/src/users-import/checkpoint.js +76 -0
  57. package/src/users-import/import.js +233 -24
  58. package/src/versions.js +80 -0
  59. package/templates/bootstrap/saaslayer-bootstrap-permission-set-inline-policy.json +148 -0
  60. package/templates/bootstrap/saaslayer-bootstrap-policy-email-sender.json +22 -0
  61. package/templates/bootstrap/saaslayer-bootstrap-policy-sms-number.json +22 -0
  62. package/templates/bootstrap/saaslayer-bootstrap-policy.json +114 -0
  63. package/templates/bootstrap/saaslayer-bootstrap-trust-policy.json +18 -0
  64. package/templates/saaslayer-foundation-region.yml +45 -1
  65. package/templates/saaslayer-foundation.yml +759 -309
@@ -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
+ }
@@ -22,6 +22,13 @@
22
22
  # (`saaslayer aws connect` / `saaslayer foundation upgrade --email-sender-domain`), so SaaSLayer's deploy role never
23
23
  # creates or verifies identities (tests/bootstrap.test.js). The DKIM records it outputs go into the customer's DNS;
24
24
  # once verified, deployments send through it via the user-service CognitoEmailSenderArn setting.
25
+ #
26
+ # OPTIONAL — the account's SMS sending number (SmsOriginationNumberType). Every SMS to a US number needs a registered
27
+ # origination identity, and one belongs to an account+region, so it lives here: one number per account+region, either
28
+ # a real toll-free number or a dev-only simulator number. Changed only by `saaslayer sms setup` / `saaslayer sms release`;
29
+ # every other path that updates this stack keeps the value and refuses a change set that replaces or removes the number
30
+ # (its approved toll-free registration would be lost). Deployments send through it via the user-service
31
+ # PhoneSmsOriginationIdentity setting (the SmsOriginationIdentityArn output).
25
32
  AWSTemplateFormatVersion: '2010-09-09'
26
33
  Description: >-
27
34
  SaaSLayer per-region foundation stack: region-bound resources for a SaaSLayer host account, starting
@@ -46,9 +53,19 @@ Parameters:
46
53
  Description: >-
47
54
  Optional domain this account sends email from (e.g. acme.com). When set, an SES identity with Easy DKIM is
48
55
  created and its three DKIM CNAME records are output for the domain's DNS. Empty = no sender domain.
56
+ SmsOriginationNumberType:
57
+ Type: String
58
+ AllowedValues: [none, toll-free, simulator]
59
+ Default: none
60
+ Description: >-
61
+ The account's SMS sending number in this region: none, a toll-free number (sends once its registration is
62
+ approved), or a simulator number (dev only; delivers to AWS simulator destinations). Set by saaslayer sms setup and
63
+ moved back to none only by saaslayer sms release.
49
64
 
50
65
  Conditions:
51
66
  HasEmailSenderDomain: !Not [!Equals [!Ref EmailSenderDomain, '']]
67
+ HasSmsOriginationNumber: !Not [!Equals [!Ref SmsOriginationNumberType, none]]
68
+ IsSmsSimulator: !Equals [!Ref SmsOriginationNumberType, simulator]
52
69
 
53
70
  Mappings:
54
71
  # Per-region foundation template version (semver). BUMP on every change so ops can tell which regional
@@ -56,7 +73,7 @@ Mappings:
56
73
  # saaslayer-foundation: major = breaking change (resource replaced/removed), minor = additive, patch = docs.
57
74
  Meta:
58
75
  FoundationRegion:
59
- Version: '1.1.0'
76
+ Version: '1.2.0'
60
77
 
61
78
  Resources:
62
79
  # Shared deployment-artifact bucket. Serverless namespaces every deploy under
@@ -124,7 +141,34 @@ Resources:
124
141
  Properties:
125
142
  EmailIdentity: !Ref EmailSenderDomain
126
143
 
144
+ # The account's SMS sending number (see the header). Delete on stack delete AND on replacement, so a number is never
145
+ # left billing outside the stack; replacement would also lose its registration, so the update paths refuse it.
146
+ # HELP/STOP replies are the carrier-required keywords; registration (`saaslayer sms register`) happens outside
147
+ # CloudFormation, which cannot register numbers.
148
+ SmsOriginationNumber:
149
+ Type: AWS::SMSVOICE::PhoneNumber
150
+ Condition: HasSmsOriginationNumber
151
+ DeletionPolicy: Delete
152
+ UpdateReplacePolicy: Delete
153
+ Properties:
154
+ IsoCountryCode: US
155
+ NumberType: !If [IsSmsSimulator, SIMULATOR, TOLL_FREE]
156
+ NumberCapabilities: [SMS]
157
+ MandatoryKeywords:
158
+ HELP:
159
+ Message: 'Account verification and sign-in codes. Msg and data rates may apply. Reply STOP to opt out.'
160
+ STOP:
161
+ Message: 'You are unsubscribed and will receive no further messages from this number.'
162
+ # The account's default sender; named senders, if any are added, carry their own saaslayer:sender value.
163
+ Tags:
164
+ - Key: saaslayer:sender
165
+ Value: default
166
+
127
167
  Outputs:
168
+ SmsOriginationIdentityArn:
169
+ Condition: HasSmsOriginationNumber
170
+ Description: ARN of the account's SMS sending number (the user-service PhoneSmsOriginationIdentity setting).
171
+ Value: !GetAtt SmsOriginationNumber.Arn
128
172
  EmailSenderIdentityArn:
129
173
  Condition: HasEmailSenderDomain
130
174
  Description: SES identity ARN of the account's email sender domain (the user-service CognitoEmailSenderArn setting).