HttpNlbIntegration Class
The Network Load Balancer integration resource for HTTP API.
Example
ts
import { HttpNlbIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
const vpc = new ec2.Vpc(this, 'VPC');
const lb = new elbv2.NetworkLoadBalancer(this, 'lb', { vpc });
const listener = lb.addListener('listener', { port: 80 });
listener.addTargets('target', {
port: 80,
});
const httpEndpoint = new apigwv2.HttpApi(this, 'HttpProxyPrivateApi', {
defaultIntegration: new HttpNlbIntegration('DefaultIntegration', listener),
});
python
from aws_cdk.aws_apigatewayv2_integrations import HttpNlbIntegration
vpc = ec2.Vpc(self, "VPC")
lb = elbv2.NetworkLoadBalancer(self, "lb", vpc=vpc)
listener = lb.add_listener("listener", port=80)
listener.add_targets("target",
port=80
)
http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
default_integration=HttpNlbIntegration("DefaultIntegration", listener)
)
java
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpNlbIntegration;
Vpc vpc = new Vpc(this, "VPC");
NetworkLoadBalancer lb = NetworkLoadBalancer.Builder.create(this, "lb").vpc(vpc).build();
NetworkListener listener = lb.addListener("listener", BaseNetworkListenerProps.builder().port(80).build());
listener.addTargets("target", AddNetworkTargetsProps.builder()
.port(80)
.build());
HttpApi httpEndpoint = HttpApi.Builder.create(this, "HttpProxyPrivateApi")
.defaultIntegration(new HttpNlbIntegration("DefaultIntegration", listener))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;
var vpc = new Vpc(this, "VPC");
var lb = new NetworkLoadBalancer(this, "lb", new NetworkLoadBalancerProps { Vpc = vpc });
var listener = lb.AddListener("listener", new BaseNetworkListenerProps { Port = 80 });
listener.AddTargets("target", new AddNetworkTargetsProps {
Port = 80
});
var httpEndpoint = new HttpApi(this, "HttpProxyPrivateApi", new HttpApiProps {
DefaultIntegration = new HttpNlbIntegration("DefaultIntegration", listener)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
vpc := ec2.NewVpc(this, jsii.String("VPC"))
lb := elbv2.NewNetworkLoadBalancer(this, jsii.String("lb"), &NetworkLoadBalancerProps{
Vpc: Vpc,
})
listener := lb.AddListener(jsii.String("listener"), &BaseNetworkListenerProps{
Port: jsii.Number(80),
})
listener.AddTargets(jsii.String("target"), &AddNetworkTargetsProps{
Port: jsii.Number(80),
})
httpEndpoint := apigwv2.NewHttpApi(this, jsii.String("HttpProxyPrivateApi"), &HttpApiProps{
DefaultIntegration: awscdk.NewHttpNlbIntegration(jsii.String("DefaultIntegration"), listener),
})
Initializer
ts
new HttpNlbIntegration(id: string, listener: INetworkListener, props?: HttpNlbIntegrationProps)
python
HttpNlbIntegration(id: str, listener: INetworkListener, props: typing.Optional[HttpNlbIntegrationProps] = None)
java
new HttpNlbIntegration(String id, INetworkListener listener, HttpNlbIntegrationProps props)
csharp
new HttpNlbIntegration(string id, INetworkListener listener, HttpNlbIntegrationProps? props = null)
go
NewHttpNlbIntegration(Id *string, Listener INetworkListener, Props HttpNlbIntegrationProps)
Methods
bind(options: HttpRouteIntegrationBindOptions): HttpRouteIntegrationConfigdef bind(self, options: HttpRouteIntegrationBindOptions) -> HttpRouteIntegrationConfigpublic HttpRouteIntegrationConfig bind(HttpRouteIntegrationBindOptions options)public HttpRouteIntegrationConfig Bind(HttpRouteIntegrationBindOptions options)func Bind(Options HttpRouteIntegrationBindOptions) HttpRouteIntegrationConfig#Bind this integration to the route.