Charlene
Charlene

Reputation: 337

Cloudformation Error - Resource of type 'AWS::ApiGateway::Model' with identifier 'Empty' already exists

I am creating an APIGateway using Cloudformation. When attempting to create via the AWS CF Console I am recieving this error: enter image description here

The EmptyModel resource is a AWS::ApiGateway::Model object that looks like this:

    EmptyModel:
    Type: "AWS::ApiGateway::Model"
    Properties:
        RestApiId: !Ref ApiGatewayRestApi
        Name: "Empty"
        Description: "This is a default empty schema model"
        Schema: |
            {
              "$schema": "http://json-schema.org/draft-04/schema#",
              "title" : "Empty Schema",
              "type" : "object"
            }
        ContentType: "application/json"

I am referencing this model on every one of my AWS::ApiGateway::Method objects in the CF Template like this: enter image description here

What am I doing wrong? I used Former2 to reverse engineer my current api and get some of this template for the new api I am creating. So I am wondering if there is just something weird in this? Any help is hella appreciated.

Upvotes: 1

Views: 1396

Answers (2)

Charlene
Charlene

Reputation: 337

I was able to identify this issue finally through much trial and error. Apparently Models are shared between all of the APIs in your account (or maybe just region)

So the error was indicating that there was already a model called "Empty" and that is because there was one, in a different API. I changed the name to "EmptyModel" and it worked great!

Upvotes: 2

Marcin
Marcin

Reputation: 238239

If you used former2 to create your template from existing resources, you can't just deploy the template obtained, as you will get the errors you are getting.

Instead you have to modify the template and import your resources to CloudFormation. Or easier, you have to delete existing resources, and then re-create them using CloudFormation.

Upvotes: 0

Related Questions