I'm setting up an AWS ELB using the aws-cdk, version 0.36.0 and I'm able to set up forwarding from port 80 to 443 using the L1 CfnListener object. Is there an L2 object that will get this done?
I've looked at ApplicationListenerRules and the general ApplicationLoadBalancer.addListener but I'm unable to find a way to add a redirectConfig to those objects.
I can do it with the CfnListener:
new elbv2.CfnListener(this, "ID", {
loadBalancerArn: lb.loadBalancerArn,
port: 80,
protocol: "HTTP",
defaultActions: [
{
type: "redirect",
redirectConfig: {
statusCode: "HTTP_301",
host: "#{host}",
path: "/#{path}",
port: "443",
protocol: "HTTPS"
}
}
]
});
I can't find anything in addListener that allows the proper statusCode, host, path, port, etc. values to be set.
One downside to adding the listener via CfnListener is that I need to manually create a security group to allow access to port 80 from the world. If I use addListener (which doesn't redirect) that rule is automatically added.