Route class
Manages an Amazon API Gateway Version 2 route. More information can be found in the Amazon API Gateway Developer Guide for WebSocket and HTTP APIs.
Example Usage
Basic
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",
});
const exampleRoute = new aws.apigatewayv2.Route("example", {
apiId: example.id,
routeKey: "$default",
});
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")
example_route = aws.apigatewayv2.Route("example",
api_id=example.id,
route_key="$default")
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",
});
var exampleRoute = new Aws.ApiGatewayV2.Route("example", new()
{
ApiId = example.Id,
RouteKey = "$default",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, 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
}
_, err = apigatewayv2.NewRoute(ctx, "example", &apigatewayv2.RouteArgs{
ApiId: example.ID().ToIDOutput().ToStringOutput(),
RouteKey: pulumi.String("$default"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_apigatewayv2_api" "example" {
name = "example-websocket-api"
protocol_type = "WEBSOCKET"
route_selection_expression = "$request.body.action"
}
resource "aws_apigatewayv2_route" "example" {
api_id = aws_apigatewayv2_api.example.id
route_key = "$default"
}
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 com.pulumi.aws.apigatewayv2.Route;
import com.pulumi.aws.apigatewayv2.RouteArgs;
import java.util.ArrayList;
import java.util.Arrays;
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());
var exampleRoute = new Route("exampleRoute", RouteArgs.builder()
.apiId(example.id())
.routeKey("$default")
.build());
}
}
resources:
example:
type: aws:apigatewayv2:Api
properties:
name: example-websocket-api
protocolType: WEBSOCKET
routeSelectionExpression: $request.body.action
exampleRoute:
type: aws:apigatewayv2:Route
name: example
properties:
apiId: ${example.id}
routeKey: $default
HTTP Proxy Integration
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",
});
const exampleIntegration = new aws.apigatewayv2.Integration("example", {
apiId: example.id,
integrationType: "HTTP_PROXY",
integrationMethod: "ANY",
integrationUri: "https://example.com/{proxy}",
});
const exampleRoute = new aws.apigatewayv2.Route("example", {
apiId: example.id,
routeKey: "ANY /example/{proxy+}",
target: pulumi.interpolate`integrations/${exampleIntegration.id}`,
});
import pulumi
import pulumi_aws as aws
example = aws.apigatewayv2.Api("example",
name="example-http-api",
protocol_type="HTTP")
example_integration = aws.apigatewayv2.Integration("example",
api_id=example.id,
integration_type="HTTP_PROXY",
integration_method="ANY",
integration_uri="https://example.com/{proxy}")
example_route = aws.apigatewayv2.Route("example",
api_id=example.id,
route_key="ANY /example/{proxy+}",
target=example_integration.id.apply(lambda id: f"integrations/{id}"))
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",
});
var exampleIntegration = new Aws.ApiGatewayV2.Integration("example", new()
{
ApiId = example.Id,
IntegrationType = "HTTP_PROXY",
IntegrationMethod = "ANY",
IntegrationUri = "https://example.com/{proxy}",
});
var exampleRoute = new Aws.ApiGatewayV2.Route("example", new()
{
ApiId = example.Id,
RouteKey = "ANY /example/{proxy+}",
Target = exampleIntegration.Id.Apply(id => $"integrations/{id}"),
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/apigatewayv2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
Name: pulumi.String("example-http-api"),
ProtocolType: pulumi.String("HTTP"),
})
if err != nil {
return err
}
exampleIntegration, err := apigatewayv2.NewIntegration(ctx, "example", &apigatewayv2.IntegrationArgs{
ApiId: example.ID().ToIDOutput().ToStringOutput(),
IntegrationType: pulumi.String("HTTP_PROXY"),
IntegrationMethod: pulumi.String("ANY"),
IntegrationUri: pulumi.String("https://example.com/{proxy}"),
})
if err != nil {
return err
}
_, err = apigatewayv2.NewRoute(ctx, "example", &apigatewayv2.RouteArgs{
ApiId: example.ID().ToIDOutput().ToStringOutput(),
RouteKey: pulumi.String("ANY /example/{proxy+}"),
Target: exampleIntegration.ID().ApplyT(func(id pulumi.ID) (string, error) {
return fmt.Sprintf("integrations/%v", id), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_apigatewayv2_api" "example" {
name = "example-http-api"
protocol_type = "HTTP"
}
resource "aws_apigatewayv2_integration" "example" {
api_id = aws_apigatewayv2_api.example.id
integration_type = "HTTP_PROXY"
integration_method = "ANY"
integration_uri = "https://example.com/{proxy}"
}
resource "aws_apigatewayv2_route" "example" {
api_id = aws_apigatewayv2_api.example.id
route_key = "ANY /example/{proxy+}"
target ="integrations/${aws_apigatewayv2_integration.example.id}"
}
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 com.pulumi.aws.apigatewayv2.Integration;
import com.pulumi.aws.apigatewayv2.IntegrationArgs;
import com.pulumi.aws.apigatewayv2.Route;
import com.pulumi.aws.apigatewayv2.RouteArgs;
import java.util.ArrayList;
import java.util.Arrays;
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());
var exampleIntegration = new Integration("exampleIntegration", IntegrationArgs.builder()
.apiId(example.id())
.integrationType("HTTP_PROXY")
.integrationMethod("ANY")
.integrationUri("https://example.com/{proxy}")
.build());
var exampleRoute = new Route("exampleRoute", RouteArgs.builder()
.apiId(example.id())
.routeKey("ANY /example/{proxy+}")
.target(exampleIntegration.id().applyValue(_id -> String.format("integrations/%s", _id)))
.build());
}
}
resources:
example:
type: aws:apigatewayv2:Api
properties:
name: example-http-api
protocolType: HTTP
exampleIntegration:
type: aws:apigatewayv2:Integration
name: example
properties:
apiId: ${example.id}
integrationType: HTTP_PROXY
integrationMethod: ANY
integrationUri: https://example.com/{proxy}
exampleRoute:
type: aws:apigatewayv2:Route
name: example
properties:
apiId: ${example.id}
routeKey: ANY /example/{proxy+}
target: integrations/${exampleIntegration.id}
Import
Identity Schema
Required
apiId(String) API identifier.id(String) Route identifier.
Optional
accountId(String) AWS Account where this resource is managed.region(String) Region where this resource is managed.
Using pulumi import, import aws.apigatewayv2.Route using apiId and id (route identifier), delimited by a /. For example:
$ pulumi import aws:apigatewayv2/route:Route example aabbccddee/1122334
> Note: The API Gateway managed route created as part of quick_create cannot be imported.
Constructors
- Route(String name, {RouteArgs? args, CustomResourceOptions? options})
-
Creates a new Route.
nameThe Pulumi resource name.argsArguments used to configure this Route. The set of arguments for Route.optionsResource options controlling this resource's behavior. - Route.reference(String urn)
- Creates a typed reference to an existing Route resource.
Properties
-
apiId
↔ Output<
String> -
API identifier.
latefinal
-
apiKeyRequired
↔ Output<
bool?> -
Whether an API key is required for the route. Defaults to
false. Supported only for WebSocket APIs.latefinal -
Authorization scopes supported by this route. The scopes are used with a JWT authorizer to authorize the method invocation.
latefinal
-
Authorization type for the route. For WebSocket APIs, valid values are
NONEfor open access,AWS_IAMfor using AWS IAM permissions, andCUSTOMfor using a Lambda authorizer. For HTTP APIs, valid values areNONEfor open access,JWTfor using JSON Web Tokens,AWS_IAMfor using AWS IAM permissions, andCUSTOMfor using a Lambda authorizer. Defaults toNONE.latefinal -
Identifier of the
aws.apigatewayv2.Authorizerresource to be associated with this route.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
modelSelectionExpression
↔ Output<
String?> -
Model selection expression for the route. Supported only for WebSocket APIs.
latefinal
-
operationName
↔ Output<
String?> -
Operation name for the route. Must be between 1 and 64 characters in length.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
requestModels
↔ Output<
Map< String, String> ?> -
Request models for the route. Supported only for WebSocket APIs.
latefinal
-
requestParameters
↔ Output<
List< RouteRequestParameter> ?> -
Request parameters for the route. Supported only for WebSocket APIs. See
requestParameterBlock below.latefinal -
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
routeKey
↔ Output<
String> -
Route key for the route. For HTTP APIs, the route key can be either
$default, or a combination of an HTTP method and resource path, for example,GET /pets.latefinal -
routeResponseSelectionExpression
↔ Output<
String?> -
Route response selection expression for the route. Supported only for WebSocket APIs.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
target
↔ Output<
String?> -
Target for the route, of the form
integrations/IntegrationID, whereIntegrationIDis the identifier of anaws.apigatewayv2.Integrationresource.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited