serverless-plugin-additional-stacks
serverless-plugin-additional-stacks copied to clipboard
Add support for multiple configuration files
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)}
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?