Api Args
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 resources.
Example Usage
Basic WebSocket API
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.apigatewayv2.Api("example", {
name: "example-websocket-api",
protocolType: "WEBSOCKET",
routeSelectionExpression: "$request.body.action",
});
import pulumi
import pulumi_aws as aws
example = aws.apigatewayv2.Api("example",
name="example-websocket-api",
protocol_type="WEBSOCKET",
route_selection_expression="$request.body.action")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.ApiGatewayV2.Api("example", new()
{
Name = "example-websocket-api",
ProtocolType = "WEBSOCKET",
RouteSelectionExpression = "$request.body.action",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
Name: pulumi.String("example-websocket-api"),
ProtocolType: pulumi.String("WEBSOCKET"),
RouteSelectionExpression: pulumi.String("$request.body.action"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.Api;
import com.pulumi.aws.apigatewayv2.ApiArgs;
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) {
var example = new Api("example", ApiArgs.builder()
.name("example-websocket-api")
.protocolType("WEBSOCKET")
.routeSelectionExpression("$request.body.action")
.build());
}
}
resources:
example:
type: aws:apigatewayv2:Api
properties:
name: example-websocket-api
protocolType: WEBSOCKET
routeSelectionExpression: $request.body.action
Basic HTTP API
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.apigatewayv2.Api("example", {
name: "example-http-api",
protocolType: "HTTP",
});
import pulumi
import pulumi_aws as aws
example = aws.apigatewayv2.Api("example",
name="example-http-api",
protocol_type="HTTP")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.ApiGatewayV2.Api("example", new()
{
Name = "example-http-api",
ProtocolType = "HTTP",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
Name: pulumi.String("example-http-api"),
ProtocolType: pulumi.String("HTTP"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.Api;
import com.pulumi.aws.apigatewayv2.ApiArgs;
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) {
var example = new Api("example", ApiArgs.builder()
.name("example-http-api")
.protocolType("HTTP")
.build());
}
}
resources:
example:
type: aws:apigatewayv2:Api
properties:
name: example-http-api
protocolType: HTTP
Import
Using pulumi import
, import aws_apigatewayv2_api
using the API identifier. For example:
$ pulumi import aws:apigatewayv2/api:Api example aabbccddee
Constructors
Properties
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.
Cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs.
Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs.
Description of the API. Must be less than or equal to 1024 characters in length.
Whether clients can invoke the API by using the default execute-api
endpoint. By default, clients can invoke the API with the default {api_id}.execute-api.{region}.amazonaws.com endpoint
. To require that clients use a custom domain name to invoke the API, disable the default endpoint.
Whether warnings should return an error while API Gateway is creating or updating the resource using an OpenAPI specification. Defaults to false
. Applicable for HTTP APIs.
The IP address types that can invoke the API. Valid values: ipv4
, dualstack
. Use ipv4
to allow only IPv4 addresses to invoke your API, or use dualstack
to allow both IPv4 and IPv6 addresses to invoke your API. Defaults to ipv4
.
API protocol. Valid values: HTTP
, WEBSOCKET
.
The route selection expression for the API. Defaults to $request.method $request.path
.
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_PROXY
or AWS_PROXY
, respectively. Applicable for HTTP APIs.