Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

AWS Classic

v4.25.0 published on Friday, Oct 15, 2021 by Pulumi

getResource

Use this data source to get the id of a Resource in API Gateway. To fetch the Resource, you must provide the REST API id as well as the full path.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var myRestApi = Output.Create(Aws.ApiGateway.GetRestApi.InvokeAsync(new Aws.ApiGateway.GetRestApiArgs
        {
            Name = "my-rest-api",
        }));
        var myResource = myRestApi.Apply(myRestApi => Output.Create(Aws.ApiGateway.GetResource.InvokeAsync(new Aws.ApiGateway.GetResourceArgs
        {
            RestApiId = myRestApi.Id,
            Path = "/endpoint/path",
        })));
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myRestApi, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
			Name: "my-rest-api",
		}, nil)
		if err != nil {
			return err
		}
		_, err = apigateway.LookupResource(ctx, &apigateway.LookupResourceArgs{
			RestApiId: myRestApi.Id,
			Path:      "/endpoint/path",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

my_rest_api = aws.apigateway.get_rest_api(name="my-rest-api")
my_resource = aws.apigateway.get_resource(rest_api_id=my_rest_api.id,
    path="/endpoint/path")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const myRestApi = aws.apigateway.getRestApi({
    name: "my-rest-api",
});
const myResource = myRestApi.then(myRestApi => aws.apigateway.getResource({
    restApiId: myRestApi.id,
    path: "/endpoint/path",
}));

Using getResource

function getResource(args: GetResourceArgs, opts?: InvokeOptions): Promise<GetResourceResult>
def get_resource(path: Optional[str] = None,
                 rest_api_id: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetResourceResult
func LookupResource(ctx *Context, args *LookupResourceArgs, opts ...InvokeOption) (*LookupResourceResult, error)

Note: This function is named LookupResource in the Go SDK.

public static class GetResource {
    public static Task<GetResourceResult> InvokeAsync(GetResourceArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Path string
The full path of the resource. If no path is found, an error will be returned.
RestApiId string
The REST API id that owns the resource. If no REST API is found, an error will be returned.
Path string
The full path of the resource. If no path is found, an error will be returned.
RestApiId string
The REST API id that owns the resource. If no REST API is found, an error will be returned.
path string
The full path of the resource. If no path is found, an error will be returned.
restApiId string
The REST API id that owns the resource. If no REST API is found, an error will be returned.
path str
The full path of the resource. If no path is found, an error will be returned.
rest_api_id str
The REST API id that owns the resource. If no REST API is found, an error will be returned.

getResource Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
ParentId string
Set to the ID of the parent Resource.
Path string
PathPart string
Set to the path relative to the parent Resource.
RestApiId string
Id string
The provider-assigned unique ID for this managed resource.
ParentId string
Set to the ID of the parent Resource.
Path string
PathPart string
Set to the path relative to the parent Resource.
RestApiId string
id string
The provider-assigned unique ID for this managed resource.
parentId string
Set to the ID of the parent Resource.
path string
pathPart string
Set to the path relative to the parent Resource.
restApiId string
id str
The provider-assigned unique ID for this managed resource.
parent_id str
Set to the ID of the parent Resource.
path str
path_part str
Set to the path relative to the parent Resource.
rest_api_id str

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.