Repository navigation
Closed
Description
This is a Bug Report
Description
When there is error in serverless.yml file then when executing for example sls deploy or sls package or any other command that reads that file, then program exits and no errors are returned in console. In the config below there is error in provider.environment.S3_BUCKET_URL:
S3_BUCKET_URL: https://s3-${opt:region, self:provider.region}.amazonaws.com/${self:provider:environment.S3_BUCKET}
It should be ${self:provider.environment.S3_BUCKET} instead of ${self:provider:environment.S3_BUCKET} (note : after provider).
Try to run sls deploy command with this config - program will just exit with no errors. Expecting to display error about bad expression in serverless.yml file.
service: hello-world
provider:
name: aws
runtime: nodejs6.10
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
S3_BUCKET: ${self:service}-${opt:stage, self:provider.stage}-audio-files
S3_BUCKET_URL: https://s3-${opt:region, self:provider.region}.amazonaws.com/${self:provider:environment.S3_BUCKET}
SNS_TOPIC_CONVERT_TEXT_TO_SPEECH: arn:aws:sns:${opt:region, self:provider.region}:#{AWS::AccountId}:convertTextToSpeech
iamRoleStatements:
- Effect: Allow
Action:
- sns:Publish
Resource: "${self:provider.environment.SNS_TOPIC_CONVERT_TEXT_TO_SPEECH}"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource: "arn:aws:s3:::${self:provider.environment.S3_BUCKET}/*"
- Effect: Allow
Action:
- polly:SynthesizeSpeech
Resource: "*"
plugins:
- serverless-offline
- serverless-pseudo-parameters
functions:
graphql:
handler: dist/app.handler
events:
- http:
path: graphql
method: post
cors: true
convertTextToSpeech:
handler: dist/tasks/convertTextToSpeech.handler
events:
- sns:
topicName: convertTextToSpeech
displayName: Convert text to speech
resources:
Resources:
AudioFilesDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}
AudioFilesBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.S3_BUCKET}
Additional Data
- Serverless Framework Version you're using: 1.26.0
- Operating System: Mac OS X
- Node.js: v8.4.0
Activity
HyperBrain commentedon Jan 31, 2018
@alekbarszczewski I agree that Serverless should print something for that error, but it is not really a bad expression, because having colons in variable names is allowed.
In you case the variable name would have been
provider:environment.S3_BUCKET.What would be an appropriate solution, would be that it emits a warning about a variable that cannot be resolved/found. This is partially related to #4687 and should be fixed with a fix for that too.
alekbarszczewski commentedon Jan 31, 2018
@HyperBrain Thanks. Just please note that
sls deploycommand just exits, it does not deploy anything (same with other command - they exit immediately after running them without making anything or printing any errors). It does not deploy service with empty/unresolved variable. Just making sure I was clear enough :).HyperBrain commentedon Jan 31, 2018
That's exactly how I understood it 😃 . So unresolved/missing but referenced variables should be recognized by Serverless. Erroring instead of warning will be better in this case.
erikerikson commentedon Feb 21, 2018
@alekbarszczewski We were having a very similar issue. Could you try out #4754? I would expect it to work or reject this on that branch, or at least to periodically report it is waiting for the resolution of the variable. Taking what you've reported, after commenting out your plugin declarations, I received: