Question:
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:
1 2 3 |
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:
1 2 3 4 5 6 7 |
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?
Answer:
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:
1 2 3 4 5 6 7 |
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:
1 2 3 4 5 6 7 |
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.