Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

filcp
Copy link

@filcp filcp commented Dec 14, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant