-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ALB Lambda Target Support #1921
Comments
Good discussion in SAM: aws/serverless-application-model#721 |
New to the project, I would like to work on this. |
@slipdexic yey! Feel free. No one is actively working on this. |
Cool, I will start working on this. |
@slipdexic are you still working on this? Also at anyone → What is the sensible way to do here, concerning the target group:
Also, since now
|
Was looking at this today. Here are the issues I found:
Here's the code I was using up to the point where I got stuck. import cdk = require("@aws-cdk/core");
import lambda = require("@aws-cdk/aws-lambda");
import elbv2 = require("@aws-cdk/aws-elasticloadbalancingv2");
import ec2 = require("@aws-cdk/aws-ec2");
export class TheStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, "Main");
const fn = new lambda.Function(this, "API", {
handler: "index",
runtime: lambda.Runtime.NODEJS_10_X,
code: new lambda.AssetCode("dist"),
vpc
});
const fnAlias = new lambda.Alias(this, "Live", {
version: fn.addVersion("1"),
aliasName: "Live"
});
const lb = new elbv2.ApplicationLoadBalancer(this, "LoadBalancer", {
vpc,
internetFacing: false
});
const listener = lb.addListener("Listener", {
port: 80,
});
listener.addTargets('Targets', {
targets: [new LambdaALBTarget(fnAlias)]
});
}
}
class LambdaALBTarget implements elbv2.IApplicationLoadBalancerTarget {
private fn: lambda.IFunction;
constructor(fn: lambda.IFunction) {
this.fn = fn;
}
attachToApplicationTargetGroup(
targetGroup: elbv2.ApplicationTargetGroup
): elbv2.LoadBalancerTargetProps {
return {
targetType: "lambda" as elbv2.TargetType,
targetJson: {
id: this.fn.functionArn
}
};
}
} |
Add a new package for ELBv2 targets called `@aws-cdk/aws-elasticloadbalancingv2-targets`. In this package, add a `LambdaTarget` which can be used to add Lambas as a backend for ALBs. `IpTarget` and `InstanceTarget` have been moved to the new package, but the originals have been left in place to not break backwards compatibility (they have been marked `@deprecated` to encourage movement to the new classes). Fixes #1921.
Also, it is not possible to enable health-check (no such property, and it is disabled by default for lambda). |
I am perhaps missing something, but I don't see support for Lambdas as an ALB target.
Please let me know if it is currently supported.
The text was updated successfully, but these errors were encountered: