Reputation: 25554
I have serverless.yaml script that use to work before - next after updating to newer version of SLS (2.72.0) I start getting warning:
Cannot resolve serverless.yaml: Variables resolution errored with:
- Cannot resolve variable at "custom.S3_BUCKET_NAME": Value not found at "self" source
my custom section looks like this:
custom:
S3_BUCKET_NAME: ${self:service}-data-${opt:stage, self:provider.stage}
s3Sync:
- bucketName: ${self:custom.S3_BUCKET_NAME}-website
localDir: ./dist
deleteRemoved: true
how I can fix this warning?
Upvotes: 12
Views: 23491
Reputation: 61
Changing the way you are writing the stage from:
self:provider.stage
To:
${sls:stage}
Should do the work!
You can find the updated documentation in: https://www.serverless.com/framework/docs/providers/aws/guide/variables or running serverless print
for a more detailed response of the problem.
Upvotes: 6
Reputation: 2427
There is a slight change in variables resolution and in your case, the best way to resolve it would be to use the following syntax:
custom:
S3_BUCKET_NAME: ${self:service}-data-${sls:stage}
s3Sync:
- bucketName: ${self:custom.S3_BUCKET_NAME}-website
localDir: ./dist
deleteRemoved: true
for resolving the stage. Alternatively, you can use old syntax, but provide explicit fallback value for stage:
custom:
S3_BUCKET_NAME: ${self:service}-data-${opt:stage, self:provider.stage, 'dev'}
s3Sync:
- bucketName: ${self:custom.S3_BUCKET_NAME}-website
localDir: ./dist
deleteRemoved: true
I would recommend going with sls:stage
version.
Upvotes: 11