I’m trying to set up a Serverless application in which objects added to an existing S3 bucket would trigger jobs in an existing StepFunctions state machine via a Lambda function. This works successfully when I deploy the application without using an existing S3 bucket, but rather using the target bucket the application creates. However, when I point to an existing S3 bucket, the stack gets created successfully, but no jobs are triggered in the state machine.
I tried getting this to work by 1) using the serverless-plugin-existing-s3
plugin and by 2) setting existing: true
under the - s3
event definition in the yml file, but neither work. Here are my serverless.yml
files I used for these 2 cases:
service: cfn-trigger-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
stage: dev
region: us-west-1
functions:
cfnPipelineTrigger:
handler: handler.upload
events:
- existingS3:
bucket: cfnbuckets-samples
event: s3:ObjectCreated:*
environment:
MY_STATE_MACHINE_ARN: arn:aws:states:us-west-1:{AccountNum}:stateMachine:cfnpipeline
iamRoleStatements:
- Effect: "Allow"
Action:
- states:*
Resource: "*"
plugins:
- serverless-step-functions
- serverless-iam-roles-per-function
- serverless-plugin-existing-s3
package:
individually: true
exclude:
- '**/*'
include:
- handler.py
service: cfn-trigger-test
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
stage: dev
region: us-west-1
functions:
cfnPipelineTrigger:
handler: handler.upload
events:
- s3:
bucket: cfnbuckets-samples
event: s3:ObjectCreated:*
existing: true
environment:
MY_STATE_MACHINE_ARN: arn:aws:states:us-west-1:{AccountNum}:stateMachine:cfnpipeline
iamRoleStatements:
- Effect: "Allow"
Action:
- states:*
Resource: "*"
plugins:
- serverless-step-functions
- serverless-iam-roles-per-function
package:
individually: true
exclude:
- '**/*'
include:
- handler.py