1. Packages
  2. AWS
  3. API Docs
  4. apigateway
  5. getRestApi
AWS v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi

aws.apigateway.getRestApi

Explore with Pulumi AI

AWS v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi

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

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

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

my_rest_api = aws.apigateway.get_rest_api(name="my-rest-api")
Copy
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 {
		_, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
			Name: "my-rest-api",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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",
    });

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

    }
}
Copy
variables:
  myRestApi:
    fn::invoke:
      function: aws:apigateway:getRestApi
      arguments:
        name: my-rest-api
Copy

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>
Copy
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]
Copy
func LookupRestApi(ctx *Context, args *LookupRestApiArgs, opts ...InvokeOption) (*LookupRestApiResult, error)
func LookupRestApiOutput(ctx *Context, args *LookupRestApiOutputArgs, opts ...InvokeOption) LookupRestApiResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
public static Output<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: aws:apigateway/getRestApi:getRestApi
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Name This property is required. string
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 This property is required. string
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 This property is required. String
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 This property is required. string
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 This property is required. str
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 This property is required. String
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>
Key-value map of resource tags.

getRestApi Result

The following output properties are available:

ApiKeySource string
Source of the API key for requests.
Arn string
ARN of the REST API.
BinaryMediaTypes List<string>
List of binary media types supported by the REST API.
Description string
Description of the REST API.
EndpointConfigurations List<GetRestApiEndpointConfiguration>
The endpoint configuration of this RestApi showing the endpoint types of the API.
ExecutionArn string
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 string
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
Source of the API key for requests.
Arn string
ARN of the REST API.
BinaryMediaTypes []string
List of binary media types supported by the REST API.
Description string
Description of the REST API.
EndpointConfigurations []GetRestApiEndpointConfiguration
The endpoint configuration of this RestApi showing the endpoint types of the API.
ExecutionArn string
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 string
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
Source of the API key for requests.
arn String
ARN of the REST API.
binaryMediaTypes List<String>
List of binary media types supported by the REST API.
description String
Description of the REST API.
endpointConfigurations List<GetRestApiEndpointConfiguration>
The endpoint configuration of this RestApi showing the endpoint types of the API.
executionArn String
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 String
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
Source of the API key for requests.
arn string
ARN of the REST API.
binaryMediaTypes string[]
List of binary media types supported by the REST API.
description string
Description of the REST API.
endpointConfigurations GetRestApiEndpointConfiguration[]
The endpoint configuration of this RestApi showing the endpoint types of the API.
executionArn string
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 string
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
Source of the API key for requests.
arn str
ARN of the REST API.
binary_media_types Sequence[str]
List of binary media types supported by the REST API.
description str
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
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 str
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
Source of the API key for requests.
arn String
ARN of the REST API.
binaryMediaTypes List<String>
List of binary media types supported by the REST API.
description String
Description of the REST API.
endpointConfigurations List<Property Map>
The endpoint configuration of this RestApi showing the endpoint types of the API.
executionArn String
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 String
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>
Key-value map of resource tags.

Supporting Types

GetRestApiEndpointConfiguration

Types This property is required. List<string>
VpcEndpointIds This property is required. List<string>
Types This property is required. []string
VpcEndpointIds This property is required. []string
types This property is required. List<String>
vpcEndpointIds This property is required. List<String>
types This property is required. string[]
vpcEndpointIds This property is required. string[]
types This property is required. Sequence[str]
vpc_endpoint_ids This property is required. Sequence[str]
types This property is required. List<String>
vpcEndpointIds This property is required. List<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 v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi