1. Packages
  2. AWS
  3. API Docs
  4. apigateway
  5. Resource
AWS v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi

aws.apigateway.Resource

Explore with Pulumi AI

Provides an API Gateway Resource.

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 myDemoResource = new aws.apigateway.Resource("MyDemoResource", {
    restApi: myDemoAPI.id,
    parentId: myDemoAPI.rootResourceId,
    pathPart: "mydemoresource",
});
Copy
import pulumi
import pulumi_aws as aws

my_demo_api = aws.apigateway.RestApi("MyDemoAPI",
    name="MyDemoAPI",
    description="This is my API for demonstration purposes")
my_demo_resource = aws.apigateway.Resource("MyDemoResource",
    rest_api=my_demo_api.id,
    parent_id=my_demo_api.root_resource_id,
    path_part="mydemoresource")
Copy
package main

import (
	"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
		}
		_, err = apigateway.NewResource(ctx, "MyDemoResource", &apigateway.ResourceArgs{
			RestApi:  myDemoAPI.ID(),
			ParentId: myDemoAPI.RootResourceId,
			PathPart: pulumi.String("mydemoresource"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
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 myDemoResource = new Aws.ApiGateway.Resource("MyDemoResource", new()
    {
        RestApi = myDemoAPI.Id,
        ParentId = myDemoAPI.RootResourceId,
        PathPart = "mydemoresource",
    });

});
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.Resource;
import com.pulumi.aws.apigateway.ResourceArgs;
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 myDemoResource = new Resource("myDemoResource", ResourceArgs.builder()
            .restApi(myDemoAPI.id())
            .parentId(myDemoAPI.rootResourceId())
            .pathPart("mydemoresource")
            .build());

    }
}
Copy
resources:
  myDemoAPI:
    type: aws:apigateway:RestApi
    name: MyDemoAPI
    properties:
      name: MyDemoAPI
      description: This is my API for demonstration purposes
  myDemoResource:
    type: aws:apigateway:Resource
    name: MyDemoResource
    properties:
      restApi: ${myDemoAPI.id}
      parentId: ${myDemoAPI.rootResourceId}
      pathPart: mydemoresource
Copy

Create Resource Resource

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

Constructor syntax

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

@overload
def Resource(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             parent_id: Optional[str] = None,
             path_part: Optional[str] = None,
             rest_api: Optional[str] = None)
func NewResource(ctx *Context, name string, args ResourceArgs, opts ...ResourceOption) (*Resource, error)
public Resource(string name, ResourceArgs args, CustomResourceOptions? opts = null)
public Resource(String name, ResourceArgs args)
public Resource(String name, ResourceArgs args, CustomResourceOptions options)
type: aws:apigateway:Resource
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. ResourceArgs
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. ResourceArgs
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. ResourceArgs
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. ResourceArgs
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. ResourceArgs
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 resourceResource = new Aws.ApiGateway.Resource("resourceResource", new()
{
    ParentId = "string",
    PathPart = "string",
    RestApi = "string",
});
Copy
example, err := apigateway.NewResource(ctx, "resourceResource", &apigateway.ResourceArgs{
	ParentId: pulumi.String("string"),
	PathPart: pulumi.String("string"),
	RestApi:  pulumi.Any("string"),
})
Copy
var resourceResource = new Resource("resourceResource", ResourceArgs.builder()
    .parentId("string")
    .pathPart("string")
    .restApi("string")
    .build());
Copy
resource_resource = aws.apigateway.Resource("resourceResource",
    parent_id="string",
    path_part="string",
    rest_api="string")
Copy
const resourceResource = new aws.apigateway.Resource("resourceResource", {
    parentId: "string",
    pathPart: "string",
    restApi: "string",
});
Copy
type: aws:apigateway:Resource
properties:
    parentId: string
    pathPart: string
    restApi: string
Copy

Resource 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 Resource resource accepts the following input properties:

ParentId This property is required. string
ID of the parent API resource
PathPart This property is required. string
Last path segment of this API resource.
RestApi
This property is required.
Changes to this property will trigger replacement.
string | string
ID of the associated REST API
ParentId This property is required. string
ID of the parent API resource
PathPart This property is required. string
Last path segment of this API resource.
RestApi
This property is required.
Changes to this property will trigger replacement.
string | string
ID of the associated REST API
parentId This property is required. String
ID of the parent API resource
pathPart This property is required. String
Last path segment of this API resource.
restApi
This property is required.
Changes to this property will trigger replacement.
String | String
ID of the associated REST API
parentId This property is required. string
ID of the parent API resource
pathPart This property is required. string
Last path segment of this API resource.
restApi
This property is required.
Changes to this property will trigger replacement.
string | RestApi
ID of the associated REST API
parent_id This property is required. str
ID of the parent API resource
path_part This property is required. str
Last path segment of this API resource.
rest_api
This property is required.
Changes to this property will trigger replacement.
str | str
ID of the associated REST API
parentId This property is required. String
ID of the parent API resource
pathPart This property is required. String
Last path segment of this API resource.
restApi
This property is required.
Changes to this property will trigger replacement.
String |
ID of the associated REST API

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Path string
Complete path for this API resource, including all parent paths.
Id string
The provider-assigned unique ID for this managed resource.
Path string
Complete path for this API resource, including all parent paths.
id String
The provider-assigned unique ID for this managed resource.
path String
Complete path for this API resource, including all parent paths.
id string
The provider-assigned unique ID for this managed resource.
path string
Complete path for this API resource, including all parent paths.
id str
The provider-assigned unique ID for this managed resource.
path str
Complete path for this API resource, including all parent paths.
id String
The provider-assigned unique ID for this managed resource.
path String
Complete path for this API resource, including all parent paths.

Look up Existing Resource Resource

Get an existing Resource 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?: ResourceState, opts?: CustomResourceOptions): Resource
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        parent_id: Optional[str] = None,
        path: Optional[str] = None,
        path_part: Optional[str] = None,
        rest_api: Optional[str] = None) -> Resource
func GetResource(ctx *Context, name string, id IDInput, state *ResourceState, opts ...ResourceOption) (*Resource, error)
public static Resource Get(string name, Input<string> id, ResourceState? state, CustomResourceOptions? opts = null)
public static Resource get(String name, Output<String> id, ResourceState state, CustomResourceOptions options)
resources:  _:    type: aws:apigateway:Resource    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:
ParentId string
ID of the parent API resource
Path string
Complete path for this API resource, including all parent paths.
PathPart string
Last path segment of this API resource.
RestApi Changes to this property will trigger replacement. string | string
ID of the associated REST API
ParentId string
ID of the parent API resource
Path string
Complete path for this API resource, including all parent paths.
PathPart string
Last path segment of this API resource.
RestApi Changes to this property will trigger replacement. string | string
ID of the associated REST API
parentId String
ID of the parent API resource
path String
Complete path for this API resource, including all parent paths.
pathPart String
Last path segment of this API resource.
restApi Changes to this property will trigger replacement. String | String
ID of the associated REST API
parentId string
ID of the parent API resource
path string
Complete path for this API resource, including all parent paths.
pathPart string
Last path segment of this API resource.
restApi Changes to this property will trigger replacement. string | RestApi
ID of the associated REST API
parent_id str
ID of the parent API resource
path str
Complete path for this API resource, including all parent paths.
path_part str
Last path segment of this API resource.
rest_api Changes to this property will trigger replacement. str | str
ID of the associated REST API
parentId String
ID of the parent API resource
path String
Complete path for this API resource, including all parent paths.
pathPart String
Last path segment of this API resource.
restApi Changes to this property will trigger replacement. String |
ID of the associated REST API

Import

Using pulumi import, import aws_api_gateway_resource using REST-API-ID/RESOURCE-ID. For example:

$ pulumi import aws:apigateway/resource:Resource example 12345abcde/67890fghij
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.