Serverless: Validation Error when nesting variable in cf reference using custom variable syntax

Created on 10 Aug 2017  ·  3Comments  ·  Source: serverless/serverless

This is a Bug Report

Description

A validation error is thrown when nesting a variable using a custom variable syntax.
This error was discovered when I tried to nest a variable inside a cloud formation reference as such: ${{cf:other-stack-${{self:provider.stage}}.Resource}}. The custom variable syntax used is shown in the serverless.yml file below.

service: addon
provider:
  name: aws
  runtime: python2.7
  stage: prod
  region: us-west-2
  profile: security
  versionFunctions: false
  variableSyntax: '\${{([\s\S]+?)}}'

plugins:
  - serverless-package-python-functions

package:
  individually: true

custom:
  test: ${{cf:core-${{self:provider.stage}}.multiStackCore}} # Error thrown here
  pkgPyFuncs:
    buildDir: build

The error thrown is

   Serverless Error ---------------------------------------

  1 validation error detected: Value 'core-${{self' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*

  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:           7.8.0
     Serverless Version:     1.18.1

This error does not occur when the default variable syntax is used.

Additional Data

  • Serverless Framework Version you're using: 1.18.1
  • Operating System: Darwin
  • Stack Trace: See above
bug

Most helpful comment

@horike37 This fix worked! Thanks!

All 3 comments

@ubaniabalogun
It seems that variableSyntax which you specify would go wrong.
I have updated variableSyntax syntax to variableSyntax: "\\${{([ :a-zA-Z0-9._,\\-\\/\\(\\)]+?)}}" on my laptop and comfirmed sls deploy is successful.

Could you please try a fix like this?

@horike37 This fix worked! Thanks!

@horike37 This fix worked! Thanks!

@ubaniabalogun great! Glad to hear that @horike37 provided the correct variableSyntax to fix that.

Thanks @horike37 for helping out! 👍

Was this page helpful?
0 / 5 - 0 ratings