get Resource
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
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",
}));
Content copied to clipboard
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")
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var myRestApi = Aws.ApiGateway.GetRestApi.Invoke(new()
{
Name = "my-rest-api",
});
var myResource = Aws.ApiGateway.GetResource.Invoke(new()
{
RestApiId = myRestApi.Apply(getRestApiResult => getRestApiResult.Id),
Path = "/endpoint/path",
});
});
Content copied to clipboard
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 {
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
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.ApigatewayFunctions;
import com.pulumi.aws.apigateway.inputs.GetRestApiArgs;
import com.pulumi.aws.apigateway.inputs.GetResourceArgs;
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) {
final var myRestApi = ApigatewayFunctions.getRestApi(GetRestApiArgs.builder()
.name("my-rest-api")
.build());
final var myResource = ApigatewayFunctions.getResource(GetResourceArgs.builder()
.restApiId(myRestApi.applyValue(getRestApiResult -> getRestApiResult.id()))
.path("/endpoint/path")
.build());
}
}
Content copied to clipboard
variables:
myRestApi:
fn::invoke:
function: aws:apigateway:getRestApi
arguments:
name: my-rest-api
myResource:
fn::invoke:
function: aws:apigateway:getResource
arguments:
restApiId: ${myRestApi.id}
path: /endpoint/path
Content copied to clipboard
Return
A collection of values returned by getResource.
Parameters
argument
A collection of arguments for invoking getResource.
Return
A collection of values returned by getResource.
Parameters
path
Full path of the resource. If no path is found, an error will be returned.
rest Api Id
REST API id that owns the resource. If no REST API is found, an error will be returned.
See also
suspend fun getResource(argument: suspend GetResourcePlainArgsBuilder.() -> Unit): GetResourceResult
Return
A collection of values returned by getResource.
Parameters
argument
Builder for com.pulumi.aws.apigateway.kotlin.inputs.GetResourcePlainArgs.