Skip to content

Commit 610c6c9

Browse files
S3 Vector: SAM template permission update (#122)
* Update sam tempalte * Update permission * Update readme * Update athena-s3vector-connector/athena-s3vector-connector.yaml Co-authored-by: Andrew Carbonetto <andrew.carbonetto@improving.com> * Update athena-s3vector-connector/README.md Co-authored-by: Andrew Carbonetto <andrew.carbonetto@improving.com> * Update athena-s3vector-connector/README.md Co-authored-by: Andrew Carbonetto <andrew.carbonetto@improving.com> * Update permission --------- Co-authored-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
1 parent 48de32b commit 610c6c9

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

athena-s3vector-connector/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The connector can be deployed directly using the provided CloudFormation templat
5757
- **AthenaCatalogName**: Name for your Lambda function (lowercase, alphanumeric, hyphens, and underscores only, 1-64 characters)
5858
- **SpillBucket**: S3 bucket name for query result spilling
5959
- **SpillPrefix**: Prefix within SpillBucket (default: athena-spill)
60+
- **S3VectorBucketName**: Name of the S3 Vector bucket to query
6061
- **LambdaTimeout**: Maximum Lambda runtime in seconds (default: 900)
6162
- **LambdaMemory**: Lambda memory in MB (default: 512)
6263
- **DisableSpillEncryption**: Set to 'true' to disable spill encryption (default: false)
@@ -87,6 +88,7 @@ For subsequent updates after initial deployment:
8788
| AthenaCatalogName | Lambda function name (must match pattern: ^[a-z0-9-_]{1,64}$) | Required |
8889
| SpillBucket | S3 bucket for spilling data | Required |
8990
| SpillPrefix | Prefix within SpillBucket | athena-spill |
91+
| S3VectorBucketName | Name of the S3 Vector bucket to query | Required |
9092
| LambdaTimeout | Maximum Lambda invocation runtime (1-900 seconds) | 900 |
9193
| LambdaMemory | Lambda memory in MB (128-3008) | 1024 |
9294
| DisableSpillEncryption | Disable encryption for spilled data | false |

athena-s3vector-connector/athena-s3vector-connector.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Parameters:
3333
Description: "Lambda memory in MB (min 128 - 3008 max)."
3434
Default: 512
3535
Type: Number
36+
S3VectorBucketName:
37+
Description: "The name of the S3 Vector bucket to query."
38+
Type: String
3639
DisableSpillEncryption:
3740
Description: "WARNING: If set to 'true' encryption for spilled data is disabled."
3841
Default: "false"
@@ -49,29 +52,40 @@ Resources:
4952
FunctionName: !Sub "${AthenaCatalogName}"
5053
Handler: "com.amazonaws.athena.connectors.s3vector.S3VectorCompositeHandler"
5154
CodeUri: "./target/athena-s3vector-connector-0.1.0.jar"
52-
Description: "A guided example for writing and deploying your own federated Amazon Athena connector for a custom source."
55+
Description: "Federated connector to query vector data stored in S3 Vector buckets."
5356
Runtime: java11
5457
Timeout: !Ref LambdaTimeout
5558
MemorySize: !Ref LambdaMemory
5659
Policies:
60+
# It's common and expected for a single Athena connector to serve queries from multiple workgroups.
61+
# However, if the lambda is restricted to a specific workgroup update the permission to "arn:aws:athena:<region>:<account-id>:workgroup/<workgroup-name>"
5762
- Statement:
5863
- Action:
5964
- athena:GetQueryExecution
6065
Effect: Allow
61-
Resource: '*'
66+
Resource: !Sub 'arn:${AWS::Partition}:athena:${AWS::Region}:${AWS::AccountId}:workgroup/*'
6267
Version: '2012-10-17'
6368

64-
# S3 Vector read access
69+
# S3 Vector list access (account-wide)
6570
- Statement:
66-
- Sid: AllowApplicationVectorAccess
71+
- Sid: AllowVectorListAccess
6772
Effect: Allow
6873
Action:
69-
- s3vectors:GetIndex
7074
- s3vectors:ListIndexes
75+
Resource: !Sub 'arn:${AWS::Partition}:s3vectors:${AWS::Region}:${AWS::AccountId}:*'
76+
77+
# S3 Vector data access (scoped to specific bucket and its indexes)
78+
- Statement:
79+
- Sid: AllowVectorDataAccess
80+
Effect: Allow
81+
Action:
82+
- s3vectors:GetIndex
7183
- s3vectors:QueryVectors
7284
- s3vectors:GetVectors
7385
- s3vectors:ListVectors
74-
Resource: '*'
86+
Resource:
87+
- !Sub 'arn:${AWS::Partition}:s3vectors:${AWS::Region}:${AWS::AccountId}:vector-bucket/${S3VectorBucketName}'
88+
- !Sub 'arn:${AWS::Partition}:s3vectors:${AWS::Region}:${AWS::AccountId}:vector-bucket/${S3VectorBucketName}/*'
7589

7690
#S3CrudPolicy allows our connector to spill large responses to S3. You can optionally replace this pre-made policy
7791
#with one that is more restrictive and can only 'put' but not read,delete, or overwrite files.

0 commit comments

Comments
 (0)