aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.61k stars 1.01k forks source link

Feature Request: Add SourceAccount on S3 Event #2099

Open LiamNguyenn opened 6 months ago

LiamNguyenn commented 6 months ago

It would be a nice feature if the on_s3_event could receive a param that controls which source account that its pointing to, and this would create X triggers for the specified Lambda. At this time, the only option is to create one trigger by decorator and modify it by hand.

@app.on_s3_event(bucket=BUCKET_NAME, source_account="123456789")
def function_name(event: S3Event):
       pass

the add permission in boto3 lib already support its:

response = client.add_permission(
    Action='lambda:InvokeFunction',
    FunctionName='my-function',
    Principal='s3.amazonaws.com',
    SourceAccount='123456789012',
    SourceArn='arn:aws:s3:::my-bucket-1xpuxmplzrlbh/*',
    StatementId='s3',
)