Skip to content
v2.274.0

ApiGatewayV2 Class ​

Use an API Gateway V2 HTTP APIs as a target for Amazon EventBridge rules.

Example ​

ts
import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';

declare const httpApi: apigwv2.HttpApi;
declare const rule: events.Rule;

rule.addTarget(new targets.ApiGatewayV2(httpApi));
python
import aws_cdk.aws_apigatewayv2 as apigwv2

# http_api: apigwv2.HttpApi
# rule: events.Rule


rule.add_target(targets.ApiGatewayV2(http_api))
java
import software.amazon.awscdk.services.apigatewayv2.*;

HttpApi httpApi;
Rule rule;


rule.addTarget(new ApiGatewayV2(httpApi));
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Apigatewayv2;

HttpApi httpApi;
Rule rule;


rule.AddTarget(new ApiGatewayV2(httpApi));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import apigwv2 "github.com/aws/aws-cdk-go/awscdk"

var httpApi HttpApi
var rule Rule


rule.AddTarget(targets.NewApiGatewayV2(httpApi))

Initializer ​

ts
new ApiGatewayV2(httpApi: IHttpApi, props?: ApiGatewayProps)
python
ApiGatewayV2(http_api: IHttpApi, props: typing.Optional[ApiGatewayProps] = None)
java
new ApiGatewayV2(IHttpApi httpApi, ApiGatewayProps props)
csharp
new ApiGatewayV2(IHttpApi httpApi, ApiGatewayProps? props = null)
go
NewApiGatewayV2(HttpApi IHttpApi, Props ApiGatewayProps)

Properties ​

iHttpApiIHttpApii_http_apiIHttpApiiHttpApiIHttpApiIHttpApiIHttpApiIHttpApiIHttpApirequired#
Returns the target IHttpApi.

Methods ​

bind(rule: IRuleRef, _id?: string): RuleTargetConfigdef bind(self, rule: IRuleRef, _id: typing.Optional[str] = None) -> RuleTargetConfigpublic RuleTargetConfig bind(IRuleRef rule, String _id)public RuleTargetConfig Bind(IRuleRef rule, string? _id = null)func Bind(Rule IRuleRef, _id *string) RuleTargetConfig#
Returns a RuleTarget that can be used to trigger this API Gateway HTTP APIs as a result from an EventBridge event.