AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.4.0 published on Wednesday, May 4, 2022 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/v5/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
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var myRestApi = Output.of(ApigatewayFunctions.getRestApi(GetRestApiArgs.builder()
            .name("my-rest-api")
            .build()));

        }
}
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",
}));
variables:
  myRestApi:
    Fn::Invoke:
      Function: aws:apigateway:getRestApi
      Arguments:
        name: my-rest-api

Using getRestApi

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 getRestApi(args: GetRestApiArgs, opts?: InvokeOptions): Promise<GetRestApiResult>
function getRestApiOutput(args: GetRestApiOutputArgs, opts?: InvokeOptions): Output<GetRestApiResult>
def get_rest_api(name: Optional[str] = None,
                 tags: Optional[Mapping[str, str]] = None,
                 opts: Optional[InvokeOptions] = None) -> GetRestApiResult
def get_rest_api_output(name: Optional[pulumi.Input[str]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetRestApiResult]
func LookupRestApi(ctx *Context, args *LookupRestApiArgs, opts ...InvokeOption) (*LookupRestApiResult, error)
func LookupRestApiOutput(ctx *Context, args *LookupRestApiOutputArgs, opts ...InvokeOption) LookupRestApiResultOutput

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

public static class GetRestApi 
{
    public static Task<GetRestApiResult> InvokeAsync(GetRestApiArgs args, InvokeOptions? opts = null)
    public static Output<GetRestApiResult> Invoke(GetRestApiInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:apigateway/getRestApi:getRestApi
  Arguments:
    # Arguments dictionary

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 Map

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.

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

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 List

The list of binary media types supported by the REST API.

description String

The description of the REST API.

endpointConfigurations ListRestApiEndpointConfiguration>

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 Integer

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

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.

apiKeySource String

The source of the API key for requests.

arn String

The ARN of the REST API.

binaryMediaTypes List

The list of binary media types supported by the REST API.

description String

The description of the REST API.

endpointConfigurations List

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 Map

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.