I am trying to deploy AWS Lambda function which is triggered when image is uploaded to S3 bucket. I tried following
service: image-resize
plugins:
- serverless-plugin-include-dependencies
package:
individually: true
excludeDevDependencies: false
custom:
bucket: stage.domain.com
provider:
name: aws
runtime: nodejs12.x
region: ${opt:region, 'us-west-2'}
stage: ${opt:stage, 'staging'}
memorySize: 128
timeout: 5
iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource: "*"
functions:
resize:
handler: handler.resize
events:
- s3:
bucket: ${self:custom.bucket}
event: s3:ObjectCreated:Put
rules:
- prefix: assets/
- suffix: .png
existing: true
When I deploy this function, I want dynamically set existing S3 bucket. How can I set multiple S3 buckets in serverless.yml
to pick up at the time of deployment based on env ?