cdk-ecs-service-extensions
cdk-ecs-service-extensions copied to clipboard
Question: Get underlying Load Balancer from `HttpLoadBalancerExtension`
Hi, I have the following CDK
const httpLoadBalancerExtension = new HttpLoadBalancerExtension();
serviceDescription.add(httpLoadBalancerExtension);
new cloudfront.Distribution(this, id + 'Distribution', {
defaultBehavior: {
origin: new origins.LoadBalancerV2Origin(httpLoadBalancerExtension.loadBalancer),
.....
I want to create a CloudFront distrubution using the Load Balancer as an origin, however the loadBalancer
property of HttpLoadBalancerExtension
is private, and I cant see any other methods which would allow access to loadBalancer
.
Woundn't the CDK code above be a legitimate reason to need access to the underlying Load Balancer?
How would I acheive what I am trying to do?
Thanks for your time.
you can try to get the loadBalancerArn from the service:
exampleServiceDescription.add(new HttpLoadBalancerExtension());
const exampleService = new Service(this, "example", {
environment: environment,
serviceDescription: exampleServiceDescription,
});
const alb = ApplicationLoadBalancer.fromLookup(this, "ImportedAlb", {
loadBalancerArn: exampleService.targetGroup?.loadBalancerArns[0],
});