alert-raincoat-81485
01/29/2021, 1:59 AMraise error_class(parsed_response, operation_name)
botocore.errorfactory.LoadBalancerNotFoundException: An error occurred (LoadBalancerNotFound) when calling the DescribeLoadBalancers operation: Load balancers '[test-lb]' not found
error: an unhandled error occurred: Program exited with non-zero exit code: 1
where i am running load balancer creating api and running boto call to get an ARN of that load balancer as
load_balancer = aws.lb.LoadBalancer( # type: ignore
"Test-LoadBalancer",
name=stacktname + "-lb",
load_balancer_type="network",
internal="true",
subnets=subnets,
enable_deletion_protection=True,
)
nlb_name = stackname + "-lb"
try:
client = boto3.client("elbv2")
except botocore.exceptions.ClientError as error:
raise error
nlb_response = client.describe_load_balancers(Names=[nlb_name])
loadbal_arn = nlb_response["LoadBalancers"][0]["LoadBalancerArn"]
Is there any way to handle this situation in pulumi or exception?billowy-army-68599
01/29/2021, 2:23 AMnlb_name
but you're setting the name of the created loadbalancer to stacktname + "-lb"
sts get-caller-identity
calldescribe_load_balancers
inside an apply
alert-raincoat-81485
01/29/2021, 2:26 AMbillowy-army-68599
01/29/2021, 2:46 AMOutput
. Output's are like a python coroutine, you need to wait until they're finished before you do the describealert-raincoat-81485
01/29/2021, 2:56 AMOutput
. Output’s are like a python coroutine, you need to wait until they’re finished before you do the describe”
And this is what i am looking for, if i can apply something like async or wait function in it.billowy-army-68599
01/29/2021, 3:01 AMalert-raincoat-81485
01/29/2021, 3:07 AMloadbalancer.arn
output is coming in form of <pulumi.output.Output object at 0x1075c4430>
but not actual a string.billowy-army-68599
01/29/2021, 3:23 AMOutput[str]
, so as I said before, you need to do that in an apply. You don't need to use boto3 at all. give me a few minutesalert-raincoat-81485
01/29/2021, 3:24 AMbillowy-army-68599
01/29/2021, 3:28 AMdef write_to_file(arn):
f = open("arn.txt", "a")
f.write(arn)
f.close()
# anything that is run inside an apply runs only when the resource has finished
# creating and has returned the value you're applying, in this case, the arn
json = lb.arn.apply(lambda a: write_to_file(arn=a))
write_to_file
only after the actual resource has been created and the API has returned a value to you. That's what apply doesalert-raincoat-81485
01/29/2021, 3:35 AMquiet-leather-94755
01/30/2021, 8:02 AMloadbalancer.arn
, you have to pass your action as a lambda that Pulumi can run once the resource referenced by the Output has been deployed / updated.