question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Referencing external config files using ${file()} fails and breaks Cloudformation template

See original GitHub issue

This is a Bug Report

Description

What Went Wrong

PR #2842 indicates that it is possible to configure a service by referencing external resource files in serverless.yml as such

service: service-name

provider:
  name: aws
  runtime: python2.7

resources:
  - ${file(./dynamodb.yml)}

However, the above configuration yields an error and results in the JSON object located at .serverless/cloudformation-template-update-stack.json being populated with the individual characters of the literal string ${file(./dynamodb.yml)}

Here’s the error message that is returned:

Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading function .zip files to S3...
Serverless: Updating Stack...

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

     Invalid template property or properties [22, 10, 11,
     12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6,
     7, 8, 9, 20, 21]

  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:       4.1.1
     Serverless Version: 1.11.0

and here’s what the .serverless/cloudformation-template-update-stack.json file looks like as a result

{
  "0": "$",
  "1": "{",
  "2": "f",
  "3": "i",
  "4": "l",
  "5": "e",
  "6": "(",
  "7": ".",
  "8": "/",
  "9": "d",
  "10": "y",
  "11": "n",
  "12": "a",
  "13": "m",
  "14": "o",
  "15": "d",
  "16": "b",
  "17": ".",
  "18": "y",
  "19": "m",
  "20": "l",
  "21": ")",
  "22": "}",
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "The AWS CloudFormation template for this Serverless application",
  "Resources": {
    "ServerlessDeploymentBucket": {
      "Type": "AWS::S3::Bucket"
    }
  },
  "Outputs": {
    "ServerlessDeploymentBucketName": {
      "Value": {
        "Ref": "ServerlessDeploymentBucket"
      }
    }
  }
}

What did you expect should have happened?

The reference ${file(./dynamodb.yml)} should have caused the Serverless Framework to load the YAML config in dynamodb.yml and use that to configure resources.

What was the config you used?

see description

What stacktrace or error message from your provider did you see?

see description

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you’re using: 1.11.0
  • Operating System: Mac OS X El Capitan 10.11.6

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dougmoscropcommented, May 15, 2017

@ubaniabalogun sorry about that, my initial implementation was naive. I’ve fixed this and added validation/tests against regression.

1reaction
dougmoscropcommented, May 11, 2017

@mt-sergio you are right but this is actually a different bug. the original bug applied to the resources section, this bug has come up and causes all file-based variables to fail as far as I can tell - not just that they’re loaded poorly as ‘keys’, but that the references remain unaffected

This was introduced via commit 7cadf284440447ea8774d8abb640323713485f22

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS CloudFormation configuration properties reference
Specify AWS CloudFormation-specific configuration properties when you choose AWS CloudFormation as a provider for the CodePipeline Deploy action.
Read more >
Load external configuration files | Filebeat Reference [8.5]
Filebeat can load external configuration files for inputs and modules, allowing you to separate your configuration into multiple smaller configuration files ...
Read more >
Config file processing in Spring Boot 2.4
So in Spring Boot 2.4 we're planning to make two significant changes to the way the properties and YAML files are loaded: Documents...
Read more >
COPY INTO <location> - Snowflake Documentation
For use in ad hoc COPY statements (statements that do not reference a named external stage). Required only for unloading data to files...
Read more >
10 Solutions to Common CloudFormation Errors - Medium
One of the most common errors encountered while using CloudFormation is a Syntax or Formatting Error. Your options for utilizing either JSON or ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found