saaslayer 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,12 @@
16
16
  # it is the deployment-artifact spine that rollback, provenance, supply-chain scanning, and audit hang off.
17
17
  # Likely future occupants (not built yet — this stack is designed to hold them): a per-region KMS key, an
18
18
  # access-log bucket, an ops-alert SNS topic, deploy-notification queues, VPC endpoints.
19
+ #
20
+ # OPTIONAL — the account's email sender domain (EmailSenderDomain). An SES identity belongs to an account+region,
21
+ # not to one deployment, so it lives here. This stack is installed with the CUSTOMER's own credentials
22
+ # (`saaslayer aws connect` / `saaslayer foundation upgrade --email-sender-domain`), so SaaSLayer's deploy role never
23
+ # creates or verifies identities (tests/bootstrap.test.js). The DKIM records it outputs go into the customer's DNS;
24
+ # once verified, deployments send through it via the user-service CognitoEmailSenderArn setting.
19
25
  AWSTemplateFormatVersion: '2010-09-09'
20
26
  Description: >-
21
27
  SaaSLayer per-region foundation stack: region-bound resources for a SaaSLayer host account, starting
@@ -33,6 +39,16 @@ Parameters:
33
39
  deployer refs.ts) and passes it, guaranteeing the bucket and the injected SERVERLESS_DEPLOYMENT_BUCKET
34
40
  agree byte-for-byte. Opaque (no raw account id) so a globally-probeable S3 name never confirms the
35
41
  account is SaaSLayer-managed.
42
+ EmailSenderDomain:
43
+ Type: String
44
+ Default: ''
45
+ AllowedPattern: '^(([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63})?$'
46
+ Description: >-
47
+ Optional domain this account sends email from (e.g. acme.com). When set, an SES identity with Easy DKIM is
48
+ created and its three DKIM CNAME records are output for the domain's DNS. Empty = no sender domain.
49
+
50
+ Conditions:
51
+ HasEmailSenderDomain: !Not [!Equals [!Ref EmailSenderDomain, '']]
36
52
 
37
53
  Mappings:
38
54
  # Per-region foundation template version (semver). BUMP on every change so ops can tell which regional
@@ -40,7 +56,7 @@ Mappings:
40
56
  # saaslayer-foundation: major = breaking change (resource replaced/removed), minor = additive, patch = docs.
41
57
  Meta:
42
58
  FoundationRegion:
43
- Version: '1.0.0'
59
+ Version: '1.1.0'
44
60
 
45
61
  Resources:
46
62
  # Shared deployment-artifact bucket. Serverless namespaces every deploy under
@@ -100,7 +116,27 @@ Resources:
100
116
  Bool:
101
117
  aws:SecureTransport: 'false'
102
118
 
119
+ # The account's email sender domain (see the header). Easy DKIM: SES generates the keys and rotates them; the
120
+ # customer adds the three CNAMEs in EmailSenderDkimRecords to the domain's DNS to verify it.
121
+ EmailSenderIdentity:
122
+ Type: AWS::SES::EmailIdentity
123
+ Condition: HasEmailSenderDomain
124
+ Properties:
125
+ EmailIdentity: !Ref EmailSenderDomain
126
+
103
127
  Outputs:
128
+ EmailSenderIdentityArn:
129
+ Condition: HasEmailSenderDomain
130
+ Description: SES identity ARN of the account's email sender domain (the user-service CognitoEmailSenderArn setting).
131
+ Value: !Sub arn:${AWS::Partition}:ses:${AWS::Region}:${AWS::AccountId}:identity/${EmailSenderDomain}
132
+ EmailSenderDkimRecords:
133
+ Condition: HasEmailSenderDomain
134
+ Description: The three DKIM CNAME records ('name CNAME value', one per line) to add to the sender domain's DNS.
135
+ Value: !Join
136
+ - "\n"
137
+ - - !Join [' ', [!GetAtt EmailSenderIdentity.DkimDNSTokenName1, CNAME, !GetAtt EmailSenderIdentity.DkimDNSTokenValue1]]
138
+ - !Join [' ', [!GetAtt EmailSenderIdentity.DkimDNSTokenName2, CNAME, !GetAtt EmailSenderIdentity.DkimDNSTokenValue2]]
139
+ - !Join [' ', [!GetAtt EmailSenderIdentity.DkimDNSTokenName3, CNAME, !GetAtt EmailSenderIdentity.DkimDNSTokenValue3]]
104
140
  ArtifactsBucketName:
105
141
  Description: Shared deployment-artifact bucket every SaaSLayer service in this account+region deploys into.
106
142
  Value: !Ref DeploymentArtifactBucket
@@ -15,7 +15,8 @@
15
15
  # 1. SaaSLayerDeploymentRole — the only cross-account WRITE entry point. Assumable solely by the
16
16
  # SaaSLayer control-plane account (ControlPlaneAccountId parameter) and only with the shared
17
17
  # ExternalId. It can drive the CloudFormation lifecycle of stacks whose names start with
18
- # StackNamePrefix (default "sl-"), read/write the deployment artifact buckets, and pass exactly
18
+ # StackNamePrefix (default "sl-"), read/write the deployment artifact buckets, update the
19
+ # configuration of StackNamePrefix functions (credential hot-swap), and pass exactly
19
20
  # one role (SaaSLayerCloudFormationExecutionRole) to CloudFormation. It cannot create IAM
20
21
  # resources or touch anything outside the managed stack namespace directly. Its only
21
22
  # sts:AssumeRole grant is into a module stack's own data-migration role
@@ -34,7 +35,8 @@
34
35
  # It carries only Get/List/Describe verbs, is tag-scoped to resources carrying
35
36
  # managed-by=saaslayer-deployer where IAM supports resource-tag conditions, and deliberately
36
37
  # excludes all data-plane reads (no S3 object reads, no DynamoDB item reads, no SSM parameter
37
- # values, no Secrets Manager secret values).
38
+ # values, no Secrets Manager secret values, no function code downloads). An explicit Deny
39
+ # (DenySecretValueReads) covers the /saaslayer/deployment/* SecureStrings and their KMS decrypt.
38
40
  #
39
41
  # SaaSLayerManagedResourceBoundary is a permissions boundary attached to every IAM role that
40
42
  # SaaSLayer module templates create: whatever a module role's own policy says, its effective
@@ -113,7 +115,7 @@ Mappings:
113
115
  # patch = comments/docs/no behavior change
114
116
  Meta:
115
117
  Foundation:
116
- Version: '5.12.0'
118
+ Version: '6.0.0'
117
119
 
118
120
  Resources:
119
121
  # The shared deployment-artifact bucket moved OUT of this account-global stack into the per-region
@@ -640,6 +642,12 @@ Resources:
640
642
  # secret from an SSM SecureString (/saaslayer/deployment/*); kms:Decrypt above covers the
641
643
  # SecureString's aws/ssm key.
642
644
  - ssm:GetParameter
645
+ # ssm SecretDelivery: user-service reads its create-only integration-credential generations by path
646
+ # (/saaslayer/deployment/<dep>/<inst>/users/integration-credentials); its role scopes the path.
647
+ - ssm:GetParametersByPath
648
+ # ssm SecretDelivery: user-service reads its permissions handoff parameters in one batch call; its role
649
+ # names the exact parameters.
650
+ - ssm:GetParameters
643
651
  Resource: '*'
644
652
  # PITR check + opt-in on-demand backup for per-service migrate roles (@saaslayer/migrations).
645
653
  # Managed-prefix tables only. The boundary is account-global and the role policies do the
@@ -779,6 +787,14 @@ Resources:
779
787
  - lambda:ListTags
780
788
  - lambda:ListVersionsByFunction
781
789
  Resource: '*'
790
+ # Env-mode credential hot-swap: revoke/rotate updates a managed function's environment directly
791
+ # (UpdateFunctionConfiguration with RevisionId, read back with GetFunctionConfiguration above) instead
792
+ # of a stack deploy. Managed-prefix functions only.
793
+ - Sid: HotSwapFunctionConfiguration
794
+ Effect: Allow
795
+ Action:
796
+ - lambda:UpdateFunctionConfiguration
797
+ Resource: !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackNamePrefix}*
782
798
  # Post-deploy SEED data-plane: after a module deploys, the deployer runs its seed
783
799
  # script under this role to make the deployment usable — bootstrap the tenant, the
784
800
  # designated first admin's deployment-administrator binding (and an explicit recovery's
@@ -937,7 +953,11 @@ Resources:
937
953
  # account + external ID) and additionally pins the session name to saaslayer-support-* so each
938
954
  # assumption is attributable in CloudTrail. Grants carry only Get/List/Describe verbs — enforced
939
955
  # by tests/bootstrap.test.js — and exclude all data-plane reads: no S3 object reads, no DynamoDB
940
- # item reads, no SSM parameter values, no Secrets Manager secret values.
956
+ # item reads, no SSM parameter values, no Secrets Manager secret values, no function code downloads.
957
+ # Function configuration and stack templates stay readable: with SecretDelivery=env (the default) they
958
+ # carry the deployment's generated secrets (an accepted risk; this role trusts the same principals as the
959
+ # deployment role). With SecretDelivery=ssm they carry only parameter paths, and DenySecretValueReads
960
+ # blocks the values.
941
961
  SaaSLayerSupportReadOnlyRole:
942
962
  Type: AWS::IAM::Role
943
963
  Properties:
@@ -993,8 +1013,8 @@ Resources:
993
1013
  - dynamodb:ListTagsOfResource
994
1014
  - events:DescribeEventBus
995
1015
  - events:ListTagsForResource
1016
+ # No lambda:GetFunction: it returns a presigned code download URL. Configuration reads stay.
996
1017
  - lambda:GetAlias
997
- - lambda:GetFunction
998
1018
  - lambda:GetFunctionConfiguration
999
1019
  - lambda:GetFunctionEventInvokeConfig
1000
1020
  - lambda:GetPolicy
@@ -1031,6 +1051,22 @@ Resources:
1031
1051
  - cloudwatch:GetDashboard
1032
1052
  - cloudwatch:ListDashboards
1033
1053
  Resource: '*'
1054
+ # DenySecretValueReads: deployments with SecretDelivery=ssm keep generated secrets as SecureStrings
1055
+ # under /saaslayer/deployment/*. The role has no Allow for them; these Denies make that explicit, in
1056
+ # every region, so no later Allow (here or attached out of band) can read a secret value.
1057
+ - Sid: DenySecretValueReads
1058
+ Effect: Deny
1059
+ Action:
1060
+ - ssm:GetParameter*
1061
+ Resource: !Sub arn:${AWS::Partition}:ssm:*:${AWS::AccountId}:parameter/saaslayer/deployment/*
1062
+ - Effect: Deny
1063
+ Action:
1064
+ - kms:Decrypt
1065
+ Resource: '*'
1066
+ Condition:
1067
+ StringLike:
1068
+ kms:ViaService: ssm.*.amazonaws.com
1069
+ kms:EncryptionContext:PARAMETER_ARN: !Sub arn:${AWS::Partition}:ssm:*:${AWS::AccountId}:parameter/saaslayer/deployment/*
1034
1070
 
1035
1071
  Outputs:
1036
1072
  DeploymentRoleArn: