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

AWS::ApiGateway::Resource

The AWS::ApiGateway::Resource resource creates a resource in an Amazon API Gateway (API Gateway) API.

Syntax

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

JSON

Copy
{ "Type" : "AWS::ApiGateway::Resource", "Properties" : { "ParentId" : String, "PathPart" : String, "RestApiId" : String } }

YAML

Copy
Type: "AWS::ApiGateway::Resource" Properties: ParentId: String PathPart: String RestApiId: String

Properties

ParentId

If you want to create a child resource, the ID of the parent resource. For resources without a parent, specify the RestApi root resource ID, such as { "Fn::GetAtt": ["MyRestApi", "RootResourceId"] }.

Required: Yes

Type: String

Update requires: Replacement

PathPart

A path name for the resource.

Required: Yes

Type: String

Update requires: Replacement

RestApiId

The ID of the RestApi resource in which you want to create this resource.

Required: Yes

Type: String

Update requires: Replacement

Return Value

Ref

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

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

Example

The following example creates a stack resource for the MyApi API.

JSON

Copy
"Stack": { "Type": "AWS::ApiGateway::Resource", "Properties": { "RestApiId": { "Ref": "MyApi" }, "ParentId": { "Fn::GetAtt": ["MyApi", "RootResourceId"] }, "PathPart": "stack" } }

YAML

Copy
Stack: Type: "AWS::ApiGateway::Resource" Properties: RestApiId: Ref: "MyApi" ParentId: Fn::GetAtt: - "MyApi" - "RootResourceId" PathPart: "stack"