Skip to content

Program exits with no error(s) when there is error inside expression in serverless.yml #4699

Closed

Description

@alekbarszczewski

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

  1. HyperBrain commented on Jan 31, 2018

    @HyperBrain
    Contributor

    @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.

  2. alekbarszczewski commented on Jan 31, 2018

    @alekbarszczewski
    Author

    @HyperBrain Thanks. Just please note that sls deploy command 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 :).

  3. HyperBrain commented on Jan 31, 2018

    @HyperBrain
    Contributor

    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.

  4. erikerikson commented on Feb 21, 2018

    @erikerikson
    Contributor

    @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:

    Serverless Error ---------------------------------------
     
      Trying to populate non string value into a string for variable ${self:provider:environment.S3_BUCKET}. Please make sure the value of the property is a string.
     
      Get Support --------------------------------------------
         Docs:          docs.serverless.com
         Bugs:          github.com/serverless/serverless/issues
         Forums:        forum.serverless.com
         Chat:          gitter.im/serverless/serverless
     
      Your Environment Information -----------------------------
         OS:                     darwin
         Node Version:           6.11.0
         Serverless Version:     1.26.0
    
  5. added this to the 1.27 milestone on Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions