Passing ServerlessDeploymentBucket as environment variable

My lambda function needs to work with a S3 bucket to store and retrieve one file. I created a resource for that until I figured out this won’t work for other AWS accounts, because the name must be universally unique.

So I thought it would be cleaner anyway if I just use the ServerlessDeploymentBucket. My approach to pass the bucket name to my nodejs app was through an environment variable.

In serverless.yml I tried with:

environment:
  SERVERLESS_BUCKET: 
    Ref: 'ServerlessDeploymentBucket'

console.log(process.env.SERVERLESS_BUCKET) would just output a “[object Object]”…