HttpAlbIntegration Class
The Application Load Balancer integration resource for HTTP API.
Example
ts
import { HttpAlbIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
const vpc = new ec2.Vpc(this, 'VPC');
const lb = new elbv2.ApplicationLoadBalancer(this, 'lb', { vpc });
const listener = lb.addListener('listener', { port: 80 });
listener.addTargets('target', {
port: 80,
});
const httpEndpoint = new apigwv2.HttpApi(this, 'HttpProxyPrivateApi', {
defaultIntegration: new HttpAlbIntegration('DefaultIntegration', listener),
});
python
from aws_cdk.aws_apigatewayv2_integrations import HttpAlbIntegration
vpc = ec2.Vpc(self, "VPC")
lb = elbv2.ApplicationLoadBalancer(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=HttpAlbIntegration("DefaultIntegration", listener)
)
java
import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpAlbIntegration;
Vpc vpc = new Vpc(this, "VPC");
ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "lb").vpc(vpc).build();
ApplicationListener listener = lb.addListener("listener", BaseApplicationListenerProps.builder().port(80).build());
listener.addTargets("target", AddApplicationTargetsProps.builder()
.port(80)
.build());
HttpApi httpEndpoint = HttpApi.Builder.create(this, "HttpProxyPrivateApi")
.defaultIntegration(new HttpAlbIntegration("DefaultIntegration", listener))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;
var vpc = new Vpc(this, "VPC");
var lb = new ApplicationLoadBalancer(this, "lb", new ApplicationLoadBalancerProps { Vpc = vpc });
var listener = lb.AddListener("listener", new BaseApplicationListenerProps { Port = 80 });
listener.AddTargets("target", new AddApplicationTargetsProps {
Port = 80
});
var httpEndpoint = new HttpApi(this, "HttpProxyPrivateApi", new HttpApiProps {
DefaultIntegration = new HttpAlbIntegration("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.NewApplicationLoadBalancer(this, jsii.String("lb"), &ApplicationLoadBalancerProps{
Vpc: Vpc,
})
listener := lb.AddListener(jsii.String("listener"), &BaseApplicationListenerProps{
Port: jsii.Number(80),
})
listener.AddTargets(jsii.String("target"), &AddApplicationTargetsProps{
Port: jsii.Number(80),
})
httpEndpoint := apigwv2.NewHttpApi(this, jsii.String("HttpProxyPrivateApi"), &HttpApiProps{
DefaultIntegration: awscdk.NewHttpAlbIntegration(jsii.String("DefaultIntegration"), listener),
})
Initializer
ts
new HttpAlbIntegration(id: string, listener: IApplicationListener, props?: HttpAlbIntegrationProps)
python
HttpAlbIntegration(id: str, listener: IApplicationListener, props: typing.Optional[HttpAlbIntegrationProps] = None)
java
new HttpAlbIntegration(String id, IApplicationListener listener, HttpAlbIntegrationProps props)
csharp
new HttpAlbIntegration(string id, IApplicationListener listener, HttpAlbIntegrationProps? props = null)
go
NewHttpAlbIntegration(Id *string, Listener IApplicationListener, Props HttpAlbIntegrationProps)
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.