1. Packages
  2. AWS Classic
  3. API Docs
  4. apigateway
  5. getResource

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

aws.apigateway.getResource

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi

    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",
    }));
    
    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")
    
    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
    	})
    }
    
    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",
        });
    
    });
    
    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());
    
        }
    }
    
    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
    

    Using getResource

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

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

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

    public static class GetResource 
    {
        public static Task<GetResourceResult> InvokeAsync(GetResourceArgs args, InvokeOptions? opts = null)
        public static Output<GetResourceResult> Invoke(GetResourceInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetResourceResult> getResource(GetResourceArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:apigateway/getResource:getResource
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Path string
    Full path of the resource. If no path is found, an error will be returned.
    RestApiId string
    REST API id that owns the resource. If no REST API is found, an error will be returned.
    Path string
    Full path of the resource. If no path is found, an error will be returned.
    RestApiId string
    REST API id that owns the resource. If no REST API is found, an error will be returned.
    path String
    Full path of the resource. If no path is found, an error will be returned.
    restApiId String
    REST API id that owns the resource. If no REST API is found, an error will be returned.
    path string
    Full path of the resource. If no path is found, an error will be returned.
    restApiId string
    REST API id that owns the resource. If no REST API is found, an error will be returned.
    path str
    Full path of the resource. If no path is found, an error will be returned.
    rest_api_id str
    REST API id that owns the resource. If no REST API is found, an error will be returned.
    path String
    Full path of the resource. If no path is found, an error will be returned.
    restApiId String
    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 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
    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

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.32.0 published on Friday, Apr 19, 2024 by Pulumi