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

Add support for multiple configuration files

Open ShaunParsons opened this issue 5 years ago • 1 comments
trafficstars

Serverless supports loading from multiple configuration files: https://www.serverless.com/framework/docs/providers/aws/guide/variables#multiple-configuration-files

Example:

resources:
  - Resources:
      ApiGatewayRestApi:
        Type: AWS::ApiGateway::RestApi

  - ${file(resources/first-cf-resources.yml)}
  - ${file(resources/second-cf-resources.yml)}

  - Outputs:
      CognitoUserPoolId:
      Value:
        Ref: CognitoUserPool

However, this does not work with additional stacks. The following config will cause stack to be an array here.

additionalStacks:
  permanent:
    - ${file(./serverless/custom/database.yml)}
    - ${file(./serverless/custom/network.yml)}

ShaunParsons avatar Jul 29 '20 13:07 ShaunParsons

At present I think my solution would be to have multiple additional stacks as follows:

additionalStacks:
  database: ${file(./serverless/custom/database.yml)}
  network: ${file(./serverless/custom/network.yml)}

But that does mean doing additional deployments.

Would the best solution here be to detect if stack is an array at this point in the code, and if it is flatten the array?

ShaunParsons avatar Jul 29 '20 13:07 ShaunParsons