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:
- Api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- Binary
Media List<string>Types 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
- Endpoint
Configuration RestApi Endpoint Configuration Args Nested argument defining API endpoint configuration including endpoint type. Defined below.
- Minimum
Compression intSize 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.
- Dictionary<string, string>
Key-value map of resource tags
- Api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- Binary
Media []stringTypes 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
- Endpoint
Configuration RestApi Endpoint Configuration Nested argument defining API endpoint configuration including endpoint type. Defined below.
- Minimum
Compression intSize 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.
- map[string]string
Key-value map of resource tags
- api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- binary
Media string[]Types 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
- endpoint
Configuration RestApi Endpoint Configuration Nested argument defining API endpoint configuration including endpoint type. Defined below.
- minimum
Compression numberSize 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.
- {[key: string]: string}
Key-value map of resource tags
- api_
key_ strsource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- binary_
media_ List[str]types 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[RestApi Endpoint Configuration] Nested argument defining API endpoint configuration including endpoint type. Defined below.
- minimum_
compression_ floatsize 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.
- 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)
- Created
Date string The creation date of the REST API
- Execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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.
- Root
Resource stringId The resource ID of the REST API’s root
- Arn string
Amazon Resource Name (ARN)
- Created
Date string The creation date of the REST API
- Execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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.
- Root
Resource stringId The resource ID of the REST API’s root
- arn string
Amazon Resource Name (ARN)
- created
Date string The creation date of the REST API
- execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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.
- root
Resource stringId 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’ssource_arnwhen 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_ strid 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): RestApistatic 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:
- Api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- Arn string
Amazon Resource Name (ARN)
- Binary
Media List<string>Types 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.
- Created
Date string The creation date of the REST API
- Description string
The description of the REST API
- Endpoint
Configuration RestApi Endpoint Configuration Args Nested argument defining API endpoint configuration including endpoint type. Defined below.
- Execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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 intSize 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.
- Root
Resource stringId The resource ID of the REST API’s root
- Dictionary<string, string>
Key-value map of resource tags
- Api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- Arn string
Amazon Resource Name (ARN)
- Binary
Media []stringTypes 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.
- Created
Date string The creation date of the REST API
- Description string
The description of the REST API
- Endpoint
Configuration RestApi Endpoint Configuration Nested argument defining API endpoint configuration including endpoint type. Defined below.
- Execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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 intSize 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.
- Root
Resource stringId The resource ID of the REST API’s root
- map[string]string
Key-value map of resource tags
- api
Key stringSource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- arn string
Amazon Resource Name (ARN)
- binary
Media string[]Types 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.
- created
Date string The creation date of the REST API
- description string
The description of the REST API
- endpoint
Configuration RestApi Endpoint Configuration Nested argument defining API endpoint configuration including endpoint type. Defined below.
- execution
Arn string The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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 numberSize 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.
- root
Resource stringId The resource ID of the REST API’s root
- {[key: string]: string}
Key-value map of resource tags
- api_
key_ strsource The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER.
- arn str
Amazon Resource Name (ARN)
- binary_
media_ List[str]types 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[RestApi Endpoint Configuration] Nested argument defining API endpoint configuration including endpoint type. Defined below.
- execution_
arn str The execution ARN part to be used in
lambda_permission’ssource_arnwhen 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_ floatsize 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_ strid The resource ID of the REST API’s root
- Dict[str, str]
Key-value map of resource tags
Supporting Types
RestApiEndpointConfiguration
- Types string
A list of endpoint types. This resource currently only supports managing a single value. Valid values:
EDGE,REGIONALorPRIVATE. If unspecified, defaults toEDGE. Must be declared asREGIONALin non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.- Vpc
Endpoint List<string>Ids 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,REGIONALorPRIVATE. If unspecified, defaults toEDGE. Must be declared asREGIONALin non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.- Vpc
Endpoint []stringIds 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,REGIONALorPRIVATE. If unspecified, defaults toEDGE. Must be declared asREGIONALin non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.- vpc
Endpoint string[]Ids 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,REGIONALorPRIVATE. If unspecified, defaults toEDGE. Must be declared asREGIONALin non-Commercial partitions. Refer to the documentation for more information on the difference between edge-optimized and regional APIs.- vpc
Endpoint List[str]Ids 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
awsTerraform Provider.