Api
Manages an Amazon API Gateway Version 2 API.
Note: Amazon API Gateway Version 2 resources are used for creating and deploying WebSocket and HTTP APIs. To create and deploy REST APIs, use Amazon API Gateway Version 1.
Example Usage
Basic WebSocket API
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.ApiGatewayV2.Api("example", new Aws.ApiGatewayV2.ApiArgs
{
ProtocolType = "WEBSOCKET",
RouteSelectionExpression = "$request.body.action",
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
ProtocolType: pulumi.String("WEBSOCKET"),
RouteSelectionExpression: pulumi.String(fmt.Sprintf("%v%v", "$", "request.body.action")),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.apigatewayv2.Api("example",
protocol_type="WEBSOCKET",
route_selection_expression="$request.body.action")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.apigatewayv2.Api("example", {
protocolType: "WEBSOCKET",
routeSelectionExpression: "$request.body.action",
});Basic HTTP API
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.ApiGatewayV2.Api("example", new Aws.ApiGatewayV2.ApiArgs
{
ProtocolType = "HTTP",
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
ProtocolType: pulumi.String("HTTP"),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.apigatewayv2.Api("example", protocol_type="HTTP")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.apigatewayv2.Api("example", {
protocolType: "HTTP",
});Create a Api Resource
new Api(name: string, args: ApiArgs, opts?: CustomResourceOptions);def Api(resource_name, opts=None, api_key_selection_expression=None, cors_configuration=None, credentials_arn=None, description=None, name=None, protocol_type=None, route_key=None, route_selection_expression=None, tags=None, target=None, version=None, __props__=None);public Api(string name, ApiArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args ApiArgs
- 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 ApiArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ApiArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
Api Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Api resource accepts the following input properties:
- Protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- Api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- Cors
Configuration ApiCors Configuration Args The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- Credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- Description string
The description of the API.
- Name string
The name of the API.
- Route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- Route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- Dictionary<string, string>
A map of tags to assign to the API.
- Target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- Version string
A version identifier for the API.
- Protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- Api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- Cors
Configuration ApiCors Configuration The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- Credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- Description string
The description of the API.
- Name string
The name of the API.
- Route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- Route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- map[string]string
A map of tags to assign to the API.
- Target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- Version string
A version identifier for the API.
- protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- cors
Configuration ApiCors Configuration The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- description string
The description of the API.
- name string
The name of the API.
- route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- {[key: string]: string}
A map of tags to assign to the API.
- target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- version string
A version identifier for the API.
- protocol_
type str The API protocol. Valid values:
HTTP,WEBSOCKET.- api_
key_ strselection_ expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- cors_
configuration Dict[ApiCors Configuration] The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- credentials_
arn str Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- description str
The description of the API.
- name str
The name of the API.
- route_
key str Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- route_
selection_ strexpression The route selection expression for the API. Defaults to
$request.method $request.path.- Dict[str, str]
A map of tags to assign to the API.
- target str
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- version str
A version identifier for the API.
Outputs
All input properties are implicitly available as output properties. Additionally, the Api resource produces the following output properties:
- Api
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- Arn string
The ARN of the API.
- Execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- Id string
- The provider-assigned unique ID for this managed resource.
- Api
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- Arn string
The ARN of the API.
- Execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- Id string
- The provider-assigned unique ID for this managed resource.
- api
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- arn string
The ARN of the API.
- execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- id string
- The provider-assigned unique ID for this managed resource.
- api_
endpoint str The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- arn str
The ARN of the API.
- execution_
arn str The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- id str
- The provider-assigned unique ID for this managed resource.
Look up an Existing Api Resource
Get an existing Api 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?: ApiState, opts?: CustomResourceOptions): Apistatic get(resource_name, id, opts=None, api_endpoint=None, api_key_selection_expression=None, arn=None, cors_configuration=None, credentials_arn=None, description=None, execution_arn=None, name=None, protocol_type=None, route_key=None, route_selection_expression=None, tags=None, target=None, version=None, __props__=None);public static Api Get(string name, Input<string> id, ApiState? 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
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- Api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- Arn string
The ARN of the API.
- Cors
Configuration ApiCors Configuration Args The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- Credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- Description string
The description of the API.
- Execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- Name string
The name of the API.
- Protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- Route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- Route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- Dictionary<string, string>
A map of tags to assign to the API.
- Target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- Version string
A version identifier for the API.
- Api
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- Api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- Arn string
The ARN of the API.
- Cors
Configuration ApiCors Configuration The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- Credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- Description string
The description of the API.
- Execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- Name string
The name of the API.
- Protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- Route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- Route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- map[string]string
A map of tags to assign to the API.
- Target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- Version string
A version identifier for the API.
- api
Endpoint string The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- api
Key stringSelection Expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- arn string
The ARN of the API.
- cors
Configuration ApiCors Configuration The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- credentials
Arn string Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- description string
The description of the API.
- execution
Arn string The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- name string
The name of the API.
- protocol
Type string The API protocol. Valid values:
HTTP,WEBSOCKET.- route
Key string Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- route
Selection stringExpression The route selection expression for the API. Defaults to
$request.method $request.path.- {[key: string]: string}
A map of tags to assign to the API.
- target string
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- version string
A version identifier for the API.
- api_
endpoint str The URI of the API, of the form
{api-id}.execute-api.{region}.amazonaws.com.- api_
key_ strselection_ expression An API key selection expression. Valid values:
$context.authorizer.usageIdentifierKey,$request.header.x-api-key. Defaults to$request.header.x-api-key. Applicable for WebSocket APIs.- arn str
The ARN of the API.
- cors_
configuration Dict[ApiCors Configuration] The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
- credentials_
arn str Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
- description str
The description of the API.
- execution_
arn str The ARN prefix to be used in an
aws.lambda.Permission’ssource_arnattribute or in anaws.iam.Policyto authorize access to the@connectionsAPI. See the Amazon API Gateway Developer Guide for details.- name str
The name of the API.
- protocol_
type str The API protocol. Valid values:
HTTP,WEBSOCKET.- route_
key str Part of quick create. Specifies any route key. Applicable for HTTP APIs.
- route_
selection_ strexpression The route selection expression for the API. Defaults to
$request.method $request.path.- Dict[str, str]
A map of tags to assign to the API.
- target str
Part of quick create. Quick create produces an API with an integration, a default catch-all route, and a default stage which is configured to automatically deploy changes. For HTTP integrations, specify a fully qualified URL. For Lambda integrations, specify a function ARN. The type of the integration will be
HTTP_PROXYorAWS_PROXY, respectively. Applicable for HTTP APIs.- version str
A version identifier for the API.
Supporting Types
ApiCorsConfiguration
- Allow
Credentials bool Whether credentials are included in the CORS request.
- Allow
Headers List<string> The set of allowed HTTP headers.
- Allow
Methods List<string> The set of allowed HTTP methods.
- Allow
Origins List<string> The set of allowed origins.
- Expose
Headers List<string> The set of exposed HTTP headers.
- Max
Age int The number of seconds that the browser should cache preflight request results.
- Allow
Credentials bool Whether credentials are included in the CORS request.
- Allow
Headers []string The set of allowed HTTP headers.
- Allow
Methods []string The set of allowed HTTP methods.
- Allow
Origins []string The set of allowed origins.
- Expose
Headers []string The set of exposed HTTP headers.
- Max
Age int The number of seconds that the browser should cache preflight request results.
- allow
Credentials boolean Whether credentials are included in the CORS request.
- allow
Headers string[] The set of allowed HTTP headers.
- allow
Methods string[] The set of allowed HTTP methods.
- allow
Origins string[] The set of allowed origins.
- expose
Headers string[] The set of exposed HTTP headers.
- max
Age number The number of seconds that the browser should cache preflight request results.
- allow
Credentials bool Whether credentials are included in the CORS request.
- allow
Headers List[str] The set of allowed HTTP headers.
- allow
Methods List[str] The set of allowed HTTP methods.
- allow
Origins List[str] The set of allowed origins.
- expose
Headers List[str] The set of exposed HTTP headers.
- max
Age float The number of seconds that the browser should cache preflight request results.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.