AWS CloudFormation
User Guide (Version )

AWS::ApiGateway::Resource

The AWS::ApiGateway::Resource resource creates a resource in an API.

Syntax

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

JSON

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

YAML

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 Values

Ref

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

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

Examples

Create resource

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

JSON

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

YAML

Stack: Type: 'AWS::ApiGateway::Resource' Properties: RestApiId: !Ref MyApi ParentId: !GetAtt - MyApi - RootResourceId PathPart: stack

See Also