serverless-plugin-additional-stacks icon indicating copy to clipboard operation
serverless-plugin-additional-stacks copied to clipboard

Doesn't accept url of file as serverless resources does

Open josersleal opened this issue 7 years ago • 5 comments
trafficstars

serverless accepts:

resources:

  • ${file(resources/s3-bucket.yml)}

This fails with ServerlessError: Template format error: Any Resources member must be an object.

Its unpractical to have all definitions in one file

josersleal avatar Sep 17 '18 10:09 josersleal

Yes you can. The structure would be like this

custom:
  additionalStacks:
    Bucket: ${file(resources/s3-bucket.yml)}

and you can add DeployParameters within that template

ghost avatar Mar 29 '19 19:03 ghost

Is there a way to include multiple files in this way?

i.e. this does not seem to work:

custom:
  additionalStacks:
    Datastores: 
        -${file(resources/s3.yml)}
        -${file(resources/dynamodb.yml)}

This would be much better for composing templates.

rpgreen avatar Jun 17 '19 18:06 rpgreen

As of today this issue is still not resolved.

In the full Serverless library, the resources and functions elements can be defined as arrays, allowing them to be defined in multiple separate files, like so:

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

This functionality is powered by the following code:

https://github.com/serverless/serverless/blob/73107822945a878abbdebe2309e8e9d87cc2858a/lib/classes/Service.js#L157

I'm going to look into making a pull request possibly soon.

EliteMasterEric avatar Apr 23 '20 04:04 EliteMasterEric

Sounds like a good idea to merge the arrays into one object in the same way as Serverless Core does.

kennu avatar Apr 23 '20 15:04 kennu

@kennu I have implemented this feature into pull request #26. A review would be greatly appreciated.

EliteMasterEric avatar Apr 23 '20 17:04 EliteMasterEric