serverless: S3 event with Ref for bucket name causes error
This is a Bug Report
Description
- What went wrong?
Tried creating an S3 event on a function, using a Ref object instead of a string for the bucket name. The object is treated like a string. The output contains a resource with logical name S3BucketObjectObject and BucketName [object Object].
- What did you expect should have happened?
Ideally, the Ref to the resource should be recognized and the new configuration should be pushed onto that object. This behavior is supported if the bucket has already been created on a lambda function, but not if the bucket was created in the resource section.
While this is not supported, an error should be thrown if the bucket name is not a string.
- What was the config you used?
service: test-buckets
provider:
name: aws
runtime: python2.7
resources:
Resources:
MyTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${opt:stage}-my-topic
BarBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${opt:stage}-bar
NotificationConfiguration:
TopicConfigurations:
- Event: "s3:ObjectCreated:*"
Topic:
Ref: MyTopic
functions:
foo:
handler: handler.foo
events:
- s3:
bucket:
Ref: BarBucket
event: s3:ObjectCreated:*
rules:
- prefix: test/
- What stacktrace or error message from your provider did you see?
An error occurred while provisioning your stack: S3BucketObjectObject
- Bucket name should not contain '['.
Similar or dependent issues:
Additional Data
- Serverless Framework Version you’re using: 1.4.0
- Operating System: macOS 10.12.1
- Stack Trace:
- Provider Error messages:
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 16 (4 by maintainers)
being able to refer to a bucket by ref would be great
It doesn’t seem to be fixed in v1.10.1, I’m facing a similar issue
and in my
serverless.ymlI have:when I replace
by
it throws the error during deployment:
Has there been a fix for this yet? Or another way to use bucket resource refs in the lambda trigger?
Everyone just uses an external plugin for that: https://github.com/matt-filion/serverless-external-s3-event
1.10 has been released yesterday: https://github.com/serverless/serverless/releases/tag/v1.10.0 https://serverless.com/blog/serverless-v1.10.0
The same issue, but I’m trying to reference a Cognito pool resource.