Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::ApiGateway::RestApi

The AWS::ApiGateway::RestApi resource contains a collection of Amazon API Gateway resources and methods that can be invoked through HTTPS endpoints. For more information, see restapi:create in the Amazon API Gateway REST API Reference.

Note

On January 1, 2016, the Swagger Specification was donated to the OpenAPI initiative, becoming the foundation of the OpenAPI Specification.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::ApiGateway::RestApi", "Properties" : { "BinaryMediaTypes" : [ String, ... ], "Body" : JSON object, "BodyS3Location" : S3Location, "CloneFrom" : String, "Description" : String, "FailOnWarnings" : Boolean, "Name" : String, "Parameters" : [ String, ... ] } }

YAML

Copy
Type: "AWS::ApiGateway::RestApi" Properties: BinaryMediaTypes: - String Body: JSON object BodyS3Location: S3Location CloneFrom: String Description: String FailOnWarnings: Boolean Name: String Parameters: - String

Properties

BinaryMediaTypes

The list of binary media types supported by the RestApi resource, such as image/png or application/octet-stream. By default, RestApi supports only UTF-8-encoded text payloads. For more information, see Enable Support for Binary Payloads in API Gateway in the API Gateway Developer Guide. Duplicates are not allowed.

Required: No

Type: List of String values

Update requires: No interruption

Body

An OpenAPI specification that defines a set of RESTful APIs in the JSON format. For YAML templates, you can also provide the specification in the YAML format.

Required: No

Type: JSON object

Update requires: No interruption

BodyS3Location

The Amazon Simple Storage Service (Amazon S3) location that points to a OpenAPI file, which defines a set of RESTful APIs in JSON or YAML format.

Required: No

Type: Amazon API Gateway RestApi S3Location

Update requires: No interruption

CloneFrom

The ID of the API Gateway RestApi resource that you want to clone.

Required: No

Type: String

Update requires: No interruption

Description

A description of the purpose of this API Gateway RestApi resource.

Required: No

Type: String

Update requires: No interruption

FailOnWarnings

If a warning occurs while API Gateway is creating the RestApi resource, indicates whether to roll back the resource.

Required: No

Type: Boolean

Update requires: No interruption

Name

A name for the API Gateway RestApi resource.

Required: Conditional. Required if you don't specify a OpenAPI definition.

Type: String

Update requires: No interruption

Parameters

Custom header parameters for the request.

Required: No

Type: List of String values

Update requires: No interruption

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the RestApi ID, such as a1bcdef2gh.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. This section lists the available attribute and a sample return value.

RootResourceId

The root resource ID for a RestApi resource, such as a0bc123d4e.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Examples

The following example create an API Gateway RestApi resource.

JSON

Copy
"MyRestApi": { "Type": "AWS::ApiGateway::RestApi", "Properties": { "Body": { OpenAPI specification } "Description": "A test API", "Name": "MyRestAPI" } }

YAML

Copy
MyRestApi: Type: "AWS::ApiGateway::RestApi" Properties: Body: OpenAPI specification Description: "A test API" Name: "MyRestAPI"