Skip to content
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

Question: Get underlying Load Balancer from HttpLoadBalancerExtension #413

Open
expertcoder opened this issue May 11, 2023 · 1 comment
Open

Comments

@expertcoder
Copy link

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.

@jcode-hub
Copy link

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],
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants