Skip to content

Commit

Permalink
Move list comprehension
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjjung committed Dec 16, 2024
1 parent 2a4aca4 commit 3228c71
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tb_pulumi/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ def __init__(
# Figure out the IPs once the instances are ready and build a load balancer targeting them
port = SERVICE_PORTS.get(engine, 5432)
inst_addrs = [instance.address for instance in instances]

def __load_balancer(ips):
return tb_pulumi.ec2.NetworkLoadBalancer(
load_balancer = tb_pulumi.ec2.NetworkLoadBalancer(
f'{name}-nlb',
project=project,
exclude_from_project=True,
Expand All @@ -422,13 +420,11 @@ def __load_balancer(ips):
target_port=port,
ingress_cidrs=[vpc_cidr],
internal=True,
ips=ips,
ips=[socket.gethostbyname(addr) for addr in inst_addrs],
security_group_description=f'Allow database traffic for {name}',
opts=pulumi.ResourceOptions(parent=self, depends_on=[*instances, *subnets]),
)

load_balancer = pulumi.Output.all(*inst_addrs).apply(lambda ips: __load_balancer(ips))

ssm_param_db_read_host = load_balancer.apply(
lambda lb: aws.ssm.Parameter(
f'{name}-ssm-dbreadhost',
Expand Down

0 comments on commit 3228c71

Please sign in to comment.