serverless-aws-documentation
serverless-aws-documentation copied to clipboard
Can't use Models defined as CloudFormation Output of different Stack
I have the following setup:
- multiple stacks with shared API Gateway (see serverless docs)
- stack 1 defines a specific model and exports it (see serverless docs)
- stack 2 should make us of the model via
Fn::ImportValue
Stack1:
custom:
documentation:
models:
- name: BadRequest400ResponseJSON
contentType: 'application/json'
schema: ....
resources:
Outputs:
BadRequest400ResponseModel:
Value: BadRequest400ResponseJSON
Export:
Name: BadRequest400ResponseModel-${self:provider.stage}
Stack2:
someFunction:
handler: myHandler
events:
documentation:
methodResponses:
- statusCode: '400'
responseModels:
"application/json":
Fn::ImportValue: 'BadRequest400ResponseModel-${self:provider.stage}'
The deployment of stack 2 fails because of Template format error: Unresolved resource dependencies [[object Object], [object Object]Model] in the Resources block of the template
.
The CloudFormation Template contains for some resources the object
DependsOn: [
"MyAweSomeModel1",
"MyAwesomeModel2",
"[object Object]Model", // <-- this causes the problem
]
The problem is line 59, which expects the resource
to be a string. If it's an object (like in my case with { "Fn::ImportValue": "<my-export-name>" }
, then it fails.
A simple workaround for me is to ignore objects in line 59 (i.e. don't add them as dependency).
The dependency is definitely needed, otherwise cloudfront won't build stuff in the right order. There needs to be special handling for your case. If the model is an object, don't add them to the dependencies.
Also a good first issue to work on :)
Of course the dependency is required. Maybe I did not express myself correctly. In my case the resource already exists, because it has been created by a different stack. Therefore that certain object should not be added to the dependencies.
I don't know if every object should be omitted or if different kind of objects (i.e. a different key than Fn::ImportValue
) have to be handled differently?!
Any update on this? With the #77 closed with the latest code we are now facing this issue. We have an errorModel defined in stack1 which we would like to import in stack 2 and we are not able to do it.
+1 any update on this? Can not use this plugin with multi-stacks currently unless someone has a clever workaround.
any update on this issue, or workaround !
Currently not. We also don't have that much time to investigate this. So if someone finds something, it would be really cool that they could fix it and make a PR to this project :)
+1 from me as well. I might be able to try and see if I can work on a fix soon.
+1 any update on this? some workaround or solution ?
In my case, when it shares same RestAPI into multiple stacks, the documentation of the last version is overriding another stacks functions documentation on swagger file.
Sorry the project that I was working on that would have allowed me to spend some time on this has been on hold. ATM, I just renamed the various components that were similar so they all had different names and didn't overwrite each other :/