aws / aws/serverless-application-model
S3 Bucket Lambda notifications in Cloudformation for an Existing Bucket
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
I am trying to add an S3 event to Lambda for an existing bucket using Cloudformation, but it is not working and says "S3 events must reference an S3 bucket in the same template". I checked few blogs but looks like this functionality is not supported via cloud formation. Would you please take it as a feature enhancement to allow the pre-existing s3 bucket as a trigger to Lambda using the Cloudformation.
Here is the CF script
```yaml
LAMBDSample:
Type: "AWS::Serverless::Function"
Properties:
FunctionName: LambdaSAMPLE
CodeUri: "../lambda/lambda_function_Sample"
Handler: "lambda_function.lambda_handler"
MemorySize: 1200
Role:
Fn::GetAtt:
- "ROLELAMBDASAMPLE"
- "Arn"
Runtime: "python3.6"
Timeout: 900
Events:
SampleFileUpload:
Type: S3
Properties:
Bucket: !FindInMap
- AccountMap
- !Ref "AWS::AccountId"
- Bucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: sample_files/
- Name: suffix
Value: .xml
VpcConfig:
SubnetIds:
- !FindInMap
- AccountMap
- !Ref "AWS::AccountId"
- PrivateSubnetAZa
- !FindInMap
- AccountMap
- !Ref "AWS::AccountId"
- PrivateSubnetAZb
SecurityGroupIds:
- !Ref SGLAMBDASAMPLE
DependsOn:
- SGLAMBDASAMPLE
- ROLELAMBDASAMPLE
```
Contributor guide
Assessment
This issue has not been assessed yet.