https://pulumi.com logo
#general
Title
# general
w

white-animal-66401

01/13/2024, 12:10 AM
And here's what the code looks like:
Copy code
export const loadBalancer = new aws.lb.LoadBalancer("app", {
  internal: false,
  loadBalancerType: "application",
  securityGroups: [securityGroups.allowHttps.id, securityGroups.allowHttp.id],
  subnetMappings: [
    { subnetId: vpc.publicSubnetIds, allocationId: eip.ipAddress.id }
  ]
});
c

cuddly-computer-18851

01/13/2024, 2:16 AM
subnetIds is an array, so you need to specify an index
Copy code
export const loadBalancer = new aws.lb.LoadBalancer("app", {
  internal: false,
  loadBalancerType: "application",
  securityGroups: [securityGroups.allowHttps.id, securityGroups.allowHttp.id],
  subnetMappings: [
    { subnetId: vpc.publicSubnetIds[0], allocationId: eip.ipAddress.id }
  ]
});
eg
w

white-animal-66401

01/13/2024, 2:18 AM
I ended up writing this
Copy code
vpc.publicSubnetIds.then(subnetIds => {
  pulumi.all(subnetIds).apply(subnetIds => {
    const subnetMappings = subnetIds.map(id => {
      return {
        subnetId: id,
        allocationId: eip.ipAddress.publicIp
      }
    });

    new awsx.lb.ApplicationLoadBalancer("app", {
      securityGroups: [securityGroups.allowHttps.id, securityGroups.allowHttp.id],
      subnetMappings: subnetMappings
    });
  });
});
But I just learned you cannot assign elastic ips to application load balancers.
c

cuddly-computer-18851

01/13/2024, 2:19 AM
You need a different EIP for each Subnet too - and yeah might need a NLB instead.
Why the requirement for static IPs?
w

white-animal-66401

01/13/2024, 2:20 AM
So I can make an A record on Cloudflare.
c

cuddly-computer-18851

01/13/2024, 2:21 AM
If you're using Cloudflare in front, a CNAME/ALIAS should be fine.
w

white-animal-66401

01/13/2024, 2:22 AM
Huh, can Cloudflare do that? Going to see.
Yeah, I can make a root level CNAME.
Is there a way to move the new application load balancer out of the promise?
So that way I can export it from the file?
c

cuddly-computer-18851

01/13/2024, 2:50 AM
the CNAME address yes