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

Model dependency causing failed CF updates #155

Description

@sahandseifi

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions