RestApi

Provides an API Gateway REST API.

Note: Amazon API Gateway Version 1 resources are used for creating and deploying REST APIs. To create and deploy WebSocket and HTTP APIs, use Amazon API Gateway Version 2.

Example Usage

Basic

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
        {
            Description = "This is my API for demonstration purposes",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigateway"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := apigateway.NewRestApi(ctx, "myDemoAPI", &apigateway.RestApiArgs{
            Description: pulumi.String("This is my API for demonstration purposes"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

my_demo_api = aws.apigateway.RestApi("myDemoAPI", description="This is my API for demonstration purposes")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", {
    description: "This is my API for demonstration purposes",
});

Regional Endpoint Type

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = new Aws.ApiGateway.RestApi("example", new Aws.ApiGateway.RestApiArgs
        {
            EndpointConfiguration = new Aws.ApiGateway.Inputs.RestApiEndpointConfigurationArgs
            {
                Types = "REGIONAL",
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigateway"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := apigateway.NewRestApi(ctx, "example", &apigateway.RestApiArgs{
            EndpointConfiguration: &apigateway.RestApiEndpointConfigurationArgs{
                Types: pulumi.String("REGIONAL"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

example = aws.apigateway.RestApi("example", endpoint_configuration={
    "types": "REGIONAL",
})
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.apigateway.RestApi("example", {
    endpointConfiguration: {
        types: "REGIONAL",
    },
});

Create a RestApi Resource

new RestApi(name: string, args?: RestApiArgs, opts?: CustomResourceOptions);
def RestApi(resource_name, opts=None, api_key_source=None, binary_media_types=None, body=None, description=None, endpoint_configuration=None, minimum_compression_size=None, name=None, policy=None, tags=None, __props__=None);
func NewRestApi(ctx *Context, name string, args *RestApiArgs, opts ...ResourceOption) (*RestApi, error)
public RestApi(string name, RestApiArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RestApiArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RestApiArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RestApiArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

RestApi Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The RestApi resource accepts the following input properties:

ApiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

BinaryMediaTypes List<string>

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

Body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

Description string

The description of the REST API

EndpointConfiguration RestApiEndpointConfigurationArgs

Nested argument defining API endpoint configuration including endpoint type. Defined below.

MinimumCompressionSize int

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

Name string

The name of the REST API

Policy string

JSON formatted policy document that controls access to the API Gateway.

Tags Dictionary<string, string>

Key-value map of resource tags

ApiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

BinaryMediaTypes []string

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

Body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

Description string

The description of the REST API

EndpointConfiguration RestApiEndpointConfiguration

Nested argument defining API endpoint configuration including endpoint type. Defined below.

MinimumCompressionSize int

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

Name string

The name of the REST API

Policy string

JSON formatted policy document that controls access to the API Gateway.

Tags map[string]string

Key-value map of resource tags

apiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

binaryMediaTypes string[]

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

description string

The description of the REST API

endpointConfiguration RestApiEndpointConfiguration

Nested argument defining API endpoint configuration including endpoint type. Defined below.

minimumCompressionSize number

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

name string

The name of the REST API

policy string

JSON formatted policy document that controls access to the API Gateway.

tags {[key: string]: string}

Key-value map of resource tags

api_key_source str

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

binary_media_types List[str]

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

body str

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

description str

The description of the REST API

endpoint_configuration Dict[RestApiEndpointConfiguration]

Nested argument defining API endpoint configuration including endpoint type. Defined below.

minimum_compression_size float

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

name str

The name of the REST API

policy str

JSON formatted policy document that controls access to the API Gateway.

tags Dict[str, str]

Key-value map of resource tags

Outputs

All input properties are implicitly available as output properties. Additionally, the RestApi resource produces the following output properties:

Arn string

Amazon Resource Name (ARN)

CreatedDate string

The creation date of the REST 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.
RootResourceId string

The resource ID of the REST API’s root

Arn string

Amazon Resource Name (ARN)

CreatedDate string

The creation date of the REST 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.
RootResourceId string

The resource ID of the REST API’s root

arn string

Amazon Resource Name (ARN)

createdDate string

The creation date of the REST 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.
rootResourceId string

The resource ID of the REST API’s root

arn str

Amazon Resource Name (ARN)

created_date str

The creation date of the REST 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.
root_resource_id str

The resource ID of the REST API’s root

Look up an Existing RestApi Resource

Get an existing RestApi resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RestApiState, opts?: CustomResourceOptions): RestApi
static get(resource_name, id, opts=None, api_key_source=None, arn=None, binary_media_types=None, body=None, created_date=None, description=None, endpoint_configuration=None, execution_arn=None, minimum_compression_size=None, name=None, policy=None, root_resource_id=None, tags=None, __props__=None);
func GetRestApi(ctx *Context, name string, id IDInput, state *RestApiState, opts ...ResourceOption) (*RestApi, error)
public static RestApi Get(string name, Input<string> id, RestApiState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

ApiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

Arn string

Amazon Resource Name (ARN)

BinaryMediaTypes List<string>

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

Body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

CreatedDate string

The creation date of the REST API

Description string

The description of the REST API

EndpointConfiguration RestApiEndpointConfigurationArgs

Nested argument defining API endpoint configuration including endpoint type. Defined below.

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.

MinimumCompressionSize int

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

Name string

The name of the REST API

Policy string

JSON formatted policy document that controls access to the API Gateway.

RootResourceId string

The resource ID of the REST API’s root

Tags Dictionary<string, string>

Key-value map of resource tags

ApiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

Arn string

Amazon Resource Name (ARN)

BinaryMediaTypes []string

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

Body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

CreatedDate string

The creation date of the REST API

Description string

The description of the REST API

EndpointConfiguration RestApiEndpointConfiguration

Nested argument defining API endpoint configuration including endpoint type. Defined below.

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.

MinimumCompressionSize int

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

Name string

The name of the REST API

Policy string

JSON formatted policy document that controls access to the API Gateway.

RootResourceId string

The resource ID of the REST API’s root

Tags map[string]string

Key-value map of resource tags

apiKeySource string

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

arn string

Amazon Resource Name (ARN)

binaryMediaTypes string[]

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

body string

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

createdDate string

The creation date of the REST API

description string

The description of the REST API

endpointConfiguration RestApiEndpointConfiguration

Nested argument defining API endpoint configuration including endpoint type. Defined below.

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.

minimumCompressionSize number

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

name string

The name of the REST API

policy string

JSON formatted policy document that controls access to the API Gateway.

rootResourceId string

The resource ID of the REST API’s root

tags {[key: string]: string}

Key-value map of resource tags

api_key_source str

The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.

arn str

Amazon Resource Name (ARN)

binary_media_types List[str]

The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads.

body str

An OpenAPI specification that defines the set of routes and integrations to create as part of the REST API.

created_date str

The creation date of the REST API

description str

The description of the REST API

endpoint_configuration Dict[RestApiEndpointConfiguration]

Nested argument defining API endpoint configuration including endpoint type. Defined below.

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.

minimum_compression_size float

Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default).

name str

The name of the REST API

policy str

JSON formatted policy document that controls access to the API Gateway.

root_resource_id str

The resource ID of the REST API’s root

tags Dict[str, str]

Key-value map of resource tags

Supporting Types

RestApiEndpointConfiguration

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Types string

A list of endpoint types. This resource currently only supports managing a single value. Valid values: EDGE, REGIONAL or PRIVATE. If unspecified, defaults to EDGE. Must be declared as REGIONAL in non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.

VpcEndpointIds List<string>

A list of VPC Endpoint Ids. It is only supported for PRIVATE endpoint type.

Types string

A list of endpoint types. This resource currently only supports managing a single value. Valid values: EDGE, REGIONAL or PRIVATE. If unspecified, defaults to EDGE. Must be declared as REGIONAL in non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.

VpcEndpointIds []string

A list of VPC Endpoint Ids. It is only supported for PRIVATE endpoint type.

types string

A list of endpoint types. This resource currently only supports managing a single value. Valid values: EDGE, REGIONAL or PRIVATE. If unspecified, defaults to EDGE. Must be declared as REGIONAL in non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.

vpcEndpointIds string[]

A list of VPC Endpoint Ids. It is only supported for PRIVATE endpoint type.

types str

A list of endpoint types. This resource currently only supports managing a single value. Valid values: EDGE, REGIONAL or PRIVATE. If unspecified, defaults to EDGE. Must be declared as REGIONAL in non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.

vpcEndpointIds List[str]

A list of VPC Endpoint Ids. It is only supported for PRIVATE endpoint type.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.