This repository has been archived by the owner on Jul 23, 2021. It is now read-only.
fix: Add check if model dependency is string in order to use !ImportValue #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using a shared API Gateway, there are times we want to share existing models. One option is to use Cloud formation cross stack reference. So I create the model and declare the Output in the main api gateway, and in the service I want to reference it, I use:
responseModels: application/json: !ImportValue MyExistingResponseModel
The problem with this approach is that when using the !ImportValue, instead of a string, this model will become an object like this:
{ 'Fn::ImportValue': 'MyExistingResponseModel' }
When adding the model dependency to Cloud Formation, the function will add it like this [object Object]Model and return an error.
Since this model already exists, so we don't need to add it to the DependsOn property. Assuming that whenever we use !ImportValue, it will generate an object, we can add a check to the addModelDependencies function to only add it when it is a string.