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

getRestApi

Use this data source to get the id and root_resource_id of a REST API in API Gateway. To fetch the REST API you must provide a name to match against. As there is no unique name constraint on REST APIs this data source will error if there is more than one match.

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

}
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 {
		_, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
			Name: "my-rest-api",
		}, 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")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const myRestApi = pulumi.output(aws.apigateway.getRestApi({
    name: "my-rest-api",
}));

Using getRestApi

function getRestApi(args: GetRestApiArgs, opts?: InvokeOptions): Promise<GetRestApiResult>
def get_rest_api(name: Optional[str] = None,
                 tags: Optional[Mapping[str, str]] = None,
                 opts: Optional[InvokeOptions] = None) -> GetRestApiResult
func LookupRestApi(ctx *Context, args *LookupRestApiArgs, opts ...InvokeOption) (*LookupRestApiResult, error)

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

public static class GetRestApi {
    public static Task<GetRestApiResult> InvokeAsync(GetRestApiArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string
The name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
Tags Dictionary<string, string>
Key-value map of resource tags.
Name string
The name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
Tags map[string]string
Key-value map of resource tags.
name string
The name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
tags {[key: string]: string}
Key-value map of resource tags.
name str
The name of the REST API to look up. If no REST API is found with this name, an error will be returned. If multiple REST APIs are found with this name, an error will be returned.
tags Mapping[str, str]
Key-value map of resource tags.

getRestApi Result

The following output properties are available:

ApiKeySource string
The source of the API key for requests.
Arn string
The ARN of the REST API.
BinaryMediaTypes List<string>
The list of binary media types supported by the REST API.
Description string
The description of the REST API.
EndpointConfigurations List<GetRestApiEndpointConfiguration>
The endpoint configuration of this RestApi showing the endpoint types of the API.
ExecutionArn string
The execution ARN part to be used in lambda_permission’s source_arn when allowing API Gateway to invoke a Lambda function, e.g. arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j, which can be concatenated with allowed stage, method and resource path.
Id string
The provider-assigned unique ID for this managed resource.
MinimumCompressionSize int
Minimum response size to compress for the REST API.
Name string
Policy string
JSON formatted policy document that controls access to the API Gateway.
RootResourceId string
Set to the ID of the API Gateway Resource on the found REST API where the route matches ‘/’.
Tags Dictionary<string, string>
Key-value map of resource tags.
ApiKeySource string
The source of the API key for requests.
Arn string
The ARN of the REST API.
BinaryMediaTypes []string
The list of binary media types supported by the REST API.
Description string
The description of the REST API.
EndpointConfigurations []GetRestApiEndpointConfiguration
The endpoint configuration of this RestApi showing the endpoint types of the API.
ExecutionArn string
The execution ARN part to be used in lambda_permission’s source_arn when allowing API Gateway to invoke a Lambda function, e.g. arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j, which can be concatenated with allowed stage, method and resource path.
Id string
The provider-assigned unique ID for this managed resource.
MinimumCompressionSize int
Minimum response size to compress for the REST API.
Name string
Policy string
JSON formatted policy document that controls access to the API Gateway.
RootResourceId string
Set to the ID of the API Gateway Resource on the found REST API where the route matches ‘/’.
Tags map[string]string
Key-value map of resource tags.
apiKeySource string
The source of the API key for requests.
arn string
The ARN of the REST API.
binaryMediaTypes string[]
The list of binary media types supported by the REST API.
description string
The description of the REST API.
endpointConfigurations GetRestApiEndpointConfiguration[]
The endpoint configuration of this RestApi showing the endpoint types of the API.
executionArn string
The execution ARN part to be used in lambda_permission’s source_arn when allowing API Gateway to invoke a Lambda function, e.g. arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j, which can be concatenated with allowed stage, method and resource path.
id string
The provider-assigned unique ID for this managed resource.
minimumCompressionSize number
Minimum response size to compress for the REST API.
name string
policy string
JSON formatted policy document that controls access to the API Gateway.
rootResourceId string
Set to the ID of the API Gateway Resource on the found REST API where the route matches ‘/’.
tags {[key: string]: string}
Key-value map of resource tags.
api_key_source str
The source of the API key for requests.
arn str
The ARN of the REST API.
binary_media_types Sequence[str]
The list of binary media types supported by the REST API.
description str
The description of the REST API.
endpoint_configurations Sequence[GetRestApiEndpointConfiguration]
The endpoint configuration of this RestApi showing the endpoint types of the API.
execution_arn str
The execution ARN part to be used in lambda_permission’s source_arn when allowing API Gateway to invoke a Lambda function, e.g. arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j, which can be concatenated with allowed stage, method and resource path.
id str
The provider-assigned unique ID for this managed resource.
minimum_compression_size int
Minimum response size to compress for the REST API.
name str
policy str
JSON formatted policy document that controls access to the API Gateway.
root_resource_id str
Set to the ID of the API Gateway Resource on the found REST API where the route matches ‘/’.
tags Mapping[str, str]
Key-value map of resource tags.

Supporting Types

GetRestApiEndpointConfiguration

Types List<string>
VpcEndpointIds List<string>
Types []string
VpcEndpointIds []string
types string[]
vpcEndpointIds string[]
types Sequence[str]
vpc_endpoint_ids Sequence[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.