I am using SAM to create few AWS resources like Lambda. I am using amplify to create S3. I need to create a eventbridge rule to trigger lambda whenever a file is uploaded to S3. But I have 2 issues:
- I am not able to create eventbridgerule using existing S3 (which is already created using amplify). I used the below code and I was not successful. Is there a way to use existing S3 bucket in SAM?
MyLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'MyLambda123'
CodeUri: code/
Handler: lambda_function.lambda_handler
Runtime: python3.7
Policies:
- Statement:
- Sid: SSMDescribeParametersPolicy
Effect: Allow
Action:
- ssm:DescribeParameters
Resource: '*'
Events:
Trigger:
Type: EventBridgeRule
Properties:
Pattern:
source:
- "aws.s3"
detail:
bucket:
name: 'someexistingbucket'
- I went ahead and created eventbridge rule manually. I know we can create a new eventbridge rule using SAM. But how can I use an existing eventbridge rule to trigger lambda function.
MyLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'MyLambda123'
CodeUri: code/
Handler: lambda_function.lambda_handler
Runtime: python3.7
Policies:
- Statement:
- Sid: SSMDescribeParametersPolicy
Effect: Allow
Action:
- ssm:DescribeParameters
Resource: '*'
Events:
Trigger:
Type: EventBridgeRule
##Somehow I need to know how to use existing eventbridge rule (which I created manually)##