Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Model dependency causing failed CF updates #155

Open
sahandseifi opened this issue Jul 30, 2020 · 1 comment
Open

Model dependency causing failed CF updates #155

sahandseifi opened this issue Jul 30, 2020 · 1 comment

Comments

@sahandseifi
Copy link

sahandseifi commented Jul 30, 2020

Imagine Mode2 references Model1 using the $ref keyword, and both models are defined in the models section of the serverless.yml file:

Model2:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Model2",
    "type": "array",
    "items": {
        "$ref": "https://apigateway.amazonaws.com/restapis/API_ID/models/Model1"
    }
}

serverless.yml

custom:
  documentation:
    models: 
      - name: "Model1"
        contentType: "application/json"
        schema: ${file(Model1.json)}
      - name: "Model2"
        contentType: "application/json"
        schema: ${file(Model2.json)}

This will cause a cloudformation update failure when Model2 is being applied earlier than Model1. This is due to the CloudFormation update template not including any dependency between the models. With Model1 not yet existing, the canonical $ref URL will be invalid and AWS will reject Model2 and fail the stack update completely.

Essentially, there is a need to specify how models depend on each other, optionally similar to other resources using the "dependsOn" keyword. Or even better, detect the dependency automatically and inject the "dependsOn" in the CF template correctly.

Can someone please confirm if this is a valid issue? I'd be happy to make a PR myself with some guidance.

@sahandseifi sahandseifi changed the title Model dependency causing failed deployments Model dependency causing failed CF updates Jul 30, 2020
@milanzivic
Copy link

I'm experiencing the same issue here. Any response from anyone related to the project?

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

No branches or pull requests

2 participants