Skip to content

Commit aa3c625

Browse files
committed
fix(helm): grant Marketplace S3 access to the named upload buckets only
1 parent 85b5b6a commit aa3c625

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

‎helm/sim/examples/aws-marketplace-prerequisites.yaml‎

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description: >-
33
Prerequisites for Sim from the AWS Marketplace container listing: Amazon RDS for PostgreSQL 17
44
(pgvector), Amazon ElastiCache (Valkey) with TLS and an auth token, and the IAM role the Sim
55
ServiceAccount assumes (IRSA) to check the Marketplace license in AWS License Manager and, with
6-
UploadBucketPrefix, to use your S3 upload buckets. Deploy it
6+
UploadBuckets, to use your S3 upload buckets. Deploy it
77
in the region and VPC of your EKS cluster, then use its outputs in values.yaml and the two
88
Kubernetes Secrets described in the listing's usage instructions.
99
@@ -37,17 +37,19 @@ Parameters:
3737
Type: String
3838
Default: cache.m7g.large
3939
Description: ElastiCache node type.
40-
UploadBucketPrefix:
41-
Type: String
40+
UploadBuckets:
41+
Type: CommaDelimitedList
4242
Default: ''
43-
AllowedPattern: '^$|^[a-z0-9][a-z0-9.-]{0,40}$'
4443
Description: >-
45-
Name prefix of the S3 buckets you create for uploads (e.g. "sim" for sim-workspace-files,
46-
sim-knowledge-base, ...). The license role is then granted read, write and multipart access
47-
to <prefix>-* buckets. Empty grants no S3 access.
44+
Exact names of the S3 buckets you create for uploads, comma-separated without spaces
45+
(S3_BUCKET_NAME and every S3_*_BUCKET_NAME in values.yaml). The license role is granted read,
46+
write and multipart access to these buckets only. Empty grants no S3 access.
4847
4948
Conditions:
50-
GrantUploadBuckets: !Not [!Equals [!Ref UploadBucketPrefix, '']]
49+
GrantUploadBuckets: !Not [!Equals [!Join ['', !Ref UploadBuckets], '']]
50+
# Fn::Join takes only a literal delimiter, so each partition's ARN prefix is spelled out.
51+
InChina: !Equals [!Ref AWS::Partition, aws-cn]
52+
InGovCloud: !Equals [!Ref AWS::Partition, aws-us-gov]
5153

5254
Resources:
5355
DatabaseSecurityGroup:
@@ -184,7 +186,17 @@ Resources:
184186
Statement:
185187
- Effect: Allow
186188
Action: s3:ListBucket
187-
Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*'
189+
Resource: !Split
190+
- ','
191+
- !Sub
192+
- 'arn:${AWS::Partition}:s3:::${Names}'
193+
- Names: !If
194+
- InChina
195+
- !Join [',arn:aws-cn:s3:::', !Ref UploadBuckets]
196+
- !If
197+
- InGovCloud
198+
- !Join [',arn:aws-us-gov:s3:::', !Ref UploadBuckets]
199+
- !Join [',arn:aws:s3:::', !Ref UploadBuckets]
188200
# Large uploads are multipart: Sim aborts and lists the parts of its own uploads.
189201
- Effect: Allow
190202
Action:
@@ -193,7 +205,17 @@ Resources:
193205
- s3:DeleteObject
194206
- s3:AbortMultipartUpload
195207
- s3:ListMultipartUploadParts
196-
Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*/*'
208+
Resource: !Split
209+
- ','
210+
- !Sub
211+
- 'arn:${AWS::Partition}:s3:::${Names}/*'
212+
- Names: !If
213+
- InChina
214+
- !Join ['/*,arn:aws-cn:s3:::', !Ref UploadBuckets]
215+
- !If
216+
- InGovCloud
217+
- !Join ['/*,arn:aws-us-gov:s3:::', !Ref UploadBuckets]
218+
- !Join ['/*,arn:aws:s3:::', !Ref UploadBuckets]
197219
- !Ref AWS::NoValue
198220

199221
Outputs:

‎helm/sim/examples/values-aws-marketplace.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
# CloudFormation template creates both in your VPC.
2424
# 3. An IAM role for the ServiceAccount below that allows license-manager:CheckoutLicense and
2525
# the S3 actions on the upload buckets listed under app.env (the CloudFormation template
26-
# creates it; set its UploadBucketPrefix parameter, e.g. "sim", to grant the S3 actions on
27-
# <prefix>-* buckets). License Manager must be set up in the account: open its console once,
28-
# or run
26+
# creates it; list those exact bucket names, comma-separated, in its UploadBuckets parameter
27+
# to grant the S3 actions on them). License Manager must be set up in the account: open its
28+
# console once, or run
2929
# aws iam create-service-linked-role --aws-service-name license-manager.amazonaws.com
3030
# 4. S3 buckets for uploads, in the region set below: one per name under app.env
3131
# (S3_BUCKET_NAME and the S3_*_BUCKET_NAME purpose buckets), e.g.

0 commit comments

Comments
 (0)