1. Packages
  2. AWS
  3. API Docs
  4. apigateway
  5. Model
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.apigateway.Model

Explore with Pulumi AI

Provides a Model for a REST API Gateway.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", {
    name: "MyDemoAPI",
    description: "This is my API for demonstration purposes",
});
const myDemoModel = new aws.apigateway.Model("MyDemoModel", {
    restApi: myDemoAPI.id,
    name: "user",
    description: "a JSON schema",
    contentType: "application/json",
    schema: JSON.stringify({
        type: "object",
    }),
});
Copy
import pulumi
import json
import pulumi_aws as aws

my_demo_api = aws.apigateway.RestApi("MyDemoAPI",
    name="MyDemoAPI",
    description="This is my API for demonstration purposes")
my_demo_model = aws.apigateway.Model("MyDemoModel",
    rest_api=my_demo_api.id,
    name="user",
    description="a JSON schema",
    content_type="application/json",
    schema=json.dumps({
        "type": "object",
    }))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myDemoAPI, err := apigateway.NewRestApi(ctx, "MyDemoAPI", &apigateway.RestApiArgs{
			Name:        pulumi.String("MyDemoAPI"),
			Description: pulumi.String("This is my API for demonstration purposes"),
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"type": "object",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = apigateway.NewModel(ctx, "MyDemoModel", &apigateway.ModelArgs{
			RestApi:     myDemoAPI.ID(),
			Name:        pulumi.String("user"),
			Description: pulumi.String("a JSON schema"),
			ContentType: pulumi.String("application/json"),
			Schema:      pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var myDemoAPI = new Aws.ApiGateway.RestApi("MyDemoAPI", new()
    {
        Name = "MyDemoAPI",
        Description = "This is my API for demonstration purposes",
    });

    var myDemoModel = new Aws.ApiGateway.Model("MyDemoModel", new()
    {
        RestApi = myDemoAPI.Id,
        Name = "user",
        Description = "a JSON schema",
        ContentType = "application/json",
        Schema = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["type"] = "object",
        }),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.RestApi;
import com.pulumi.aws.apigateway.RestApiArgs;
import com.pulumi.aws.apigateway.Model;
import com.pulumi.aws.apigateway.ModelArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myDemoAPI = new RestApi("myDemoAPI", RestApiArgs.builder()
            .name("MyDemoAPI")
            .description("This is my API for demonstration purposes")
            .build());

        var myDemoModel = new Model("myDemoModel", ModelArgs.builder()
            .restApi(myDemoAPI.id())
            .name("user")
            .description("a JSON schema")
            .contentType("application/json")
            .schema(serializeJson(
                jsonObject(
                    jsonProperty("type", "object")
                )))
            .build());

    }
}
Copy
resources:
  myDemoAPI:
    type: aws:apigateway:RestApi
    name: MyDemoAPI
    properties:
      name: MyDemoAPI
      description: This is my API for demonstration purposes
  myDemoModel:
    type: aws:apigateway:Model
    name: MyDemoModel
    properties:
      restApi: ${myDemoAPI.id}
      name: user
      description: a JSON schema
      contentType: application/json
      schema:
        fn::toJSON:
          type: object
Copy

Create Model Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Model(name: string, args: ModelArgs, opts?: CustomResourceOptions);
@overload
def Model(resource_name: str,
          args: ModelArgs,
          opts: Optional[ResourceOptions] = None)

@overload
def Model(resource_name: str,
          opts: Optional[ResourceOptions] = None,
          content_type: Optional[str] = None,
          rest_api: Optional[str] = None,
          description: Optional[str] = None,
          name: Optional[str] = None,
          schema: Optional[str] = None)
func NewModel(ctx *Context, name string, args ModelArgs, opts ...ResourceOption) (*Model, error)
public Model(string name, ModelArgs args, CustomResourceOptions? opts = null)
public Model(String name, ModelArgs args)
public Model(String name, ModelArgs args, CustomResourceOptions options)
type: aws:apigateway:Model
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ModelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ModelArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ModelArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ModelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ModelArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var modelResource = new Aws.ApiGateway.Model("modelResource", new()
{
    ContentType = "string",
    RestApi = "string",
    Description = "string",
    Name = "string",
    Schema = "string",
});
Copy
example, err := apigateway.NewModel(ctx, "modelResource", &apigateway.ModelArgs{
	ContentType: pulumi.String("string"),
	RestApi:     pulumi.Any("string"),
	Description: pulumi.String("string"),
	Name:        pulumi.String("string"),
	Schema:      pulumi.String("string"),
})
Copy
var modelResource = new Model("modelResource", ModelArgs.builder()
    .contentType("string")
    .restApi("string")
    .description("string")
    .name("string")
    .schema("string")
    .build());
Copy
model_resource = aws.apigateway.Model("modelResource",
    content_type="string",
    rest_api="string",
    description="string",
    name="string",
    schema="string")
Copy
const modelResource = new aws.apigateway.Model("modelResource", {
    contentType: "string",
    restApi: "string",
    description: "string",
    name: "string",
    schema: "string",
});
Copy
type: aws:apigateway:Model
properties:
    contentType: string
    description: string
    name: string
    restApi: string
    schema: string
Copy

Model Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Model resource accepts the following input properties:

ContentType
This property is required.
Changes to this property will trigger replacement.
string
Content type of the model
RestApi
This property is required.
Changes to this property will trigger replacement.
string | string
ID of the associated REST API
Description string
Description of the model
Name Changes to this property will trigger replacement. string
Name of the model
Schema string
Schema of the model in a JSON form
ContentType
This property is required.
Changes to this property will trigger replacement.
string
Content type of the model
RestApi
This property is required.
Changes to this property will trigger replacement.
string | string
ID of the associated REST API
Description string
Description of the model
Name Changes to this property will trigger replacement. string
Name of the model
Schema string
Schema of the model in a JSON form
contentType
This property is required.
Changes to this property will trigger replacement.
String
Content type of the model
restApi
This property is required.
Changes to this property will trigger replacement.
String | String
ID of the associated REST API
description String
Description of the model
name Changes to this property will trigger replacement. String
Name of the model
schema String
Schema of the model in a JSON form
contentType
This property is required.
Changes to this property will trigger replacement.
string
Content type of the model
restApi
This property is required.
Changes to this property will trigger replacement.
string | RestApi
ID of the associated REST API
description string
Description of the model
name Changes to this property will trigger replacement. string
Name of the model
schema string
Schema of the model in a JSON form
content_type
This property is required.
Changes to this property will trigger replacement.
str
Content type of the model
rest_api
This property is required.
Changes to this property will trigger replacement.
str | str
ID of the associated REST API
description str
Description of the model
name Changes to this property will trigger replacement. str
Name of the model
schema str
Schema of the model in a JSON form
contentType
This property is required.
Changes to this property will trigger replacement.
String
Content type of the model
restApi
This property is required.
Changes to this property will trigger replacement.
String |
ID of the associated REST API
description String
Description of the model
name Changes to this property will trigger replacement. String
Name of the model
schema String
Schema of the model in a JSON form

Outputs

All input properties are implicitly available as output properties. Additionally, the Model resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Model Resource

Get an existing Model resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ModelState, opts?: CustomResourceOptions): Model
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        content_type: Optional[str] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        rest_api: Optional[str] = None,
        schema: Optional[str] = None) -> Model
func GetModel(ctx *Context, name string, id IDInput, state *ModelState, opts ...ResourceOption) (*Model, error)
public static Model Get(string name, Input<string> id, ModelState? state, CustomResourceOptions? opts = null)
public static Model get(String name, Output<String> id, ModelState state, CustomResourceOptions options)
resources:  _:    type: aws:apigateway:Model    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ContentType Changes to this property will trigger replacement. string
Content type of the model
Description string
Description of the model
Name Changes to this property will trigger replacement. string
Name of the model
RestApi Changes to this property will trigger replacement. string | string
ID of the associated REST API
Schema string
Schema of the model in a JSON form
ContentType Changes to this property will trigger replacement. string
Content type of the model
Description string
Description of the model
Name Changes to this property will trigger replacement. string
Name of the model
RestApi Changes to this property will trigger replacement. string | string
ID of the associated REST API
Schema string
Schema of the model in a JSON form
contentType Changes to this property will trigger replacement. String
Content type of the model
description String
Description of the model
name Changes to this property will trigger replacement. String
Name of the model
restApi Changes to this property will trigger replacement. String | String
ID of the associated REST API
schema String
Schema of the model in a JSON form
contentType Changes to this property will trigger replacement. string
Content type of the model
description string
Description of the model
name Changes to this property will trigger replacement. string
Name of the model
restApi Changes to this property will trigger replacement. string | RestApi
ID of the associated REST API
schema string
Schema of the model in a JSON form
content_type Changes to this property will trigger replacement. str
Content type of the model
description str
Description of the model
name Changes to this property will trigger replacement. str
Name of the model
rest_api Changes to this property will trigger replacement. str | str
ID of the associated REST API
schema str
Schema of the model in a JSON form
contentType Changes to this property will trigger replacement. String
Content type of the model
description String
Description of the model
name Changes to this property will trigger replacement. String
Name of the model
restApi Changes to this property will trigger replacement. String |
ID of the associated REST API
schema String
Schema of the model in a JSON form

Import

Using pulumi import, import aws_api_gateway_model using REST-API-ID/NAME. For example:

$ pulumi import aws:apigateway/model:Model example 12345abcde/example
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.