Hello folks, i am running into issue of ``` raise...
# aws
Hello folks, i am running into issue of
Copy code
raise 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
Copy code
load_balancer = aws.lb.LoadBalancer(  # type: ignore
    name=stacktname + "-lb",

nlb_name = stackname + "-lb"
    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?
you're describe the loadbalancer
but you're setting the name of the created loadbalancer to
stacktname + "-lb"
is that correct?
ah yes, looks like it is
so, the most likely scenario is either: 1) that the boto client you've created might not be using the same creds as your Pulumi program 2 )or the boto call is running before your loadbalancer is created
for 1), i'd verify from your boto client it has the right creds with an
sts get-caller-identity
and for 2), run the
inside an
I'm on my phone right now, so if you need help with 2), @ me me in a couple hours and I can explain further
🙂 1
Yes the stackname is a var assigned as a part of environment var.
well yes, when i am running pulumi preview, or up. The boto runs first or parallel with loadbalancer API.
That’s the way it’s not able to find the load bal.
STS won’t be an issue because when i am running boto3 API on existing Load-balancer, i am getting expected result. So the problem here is, boto is not able to find the Load-balancer because the resource has not been created in the current stack yet.
I appreciate your response, whenever you get free.
so you definitely need to run the describe load balancer call in the apply, in that case
pulumi creates your load balancer and then when it's been done, it returns a bunch of information about the created LB in an
. Output's are like a python coroutine, you need to wait until they're finished before you do the describe
âś… 1
Yes i initially tried to get “Load-Balancer.arn” as a output, but it doesn’t return as a string or expected output. All i need here is a arn string output for me to use in other resource.
I didn’t get your statement, “so you definitely need to run the describe load balancer call in the apply, in that case”
I agree on your point, “pulumi creates your load balancer and then when it’s been done, it returns a bunch of information about the created LB in an 
. 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.
it's not returning an arn at all? what are you trying to pass the arn to, another resource?
Yes i am trying to pass arn (str) to another resource which isn’t part of pulumi. Basically str arn is being appended to one of the json file.
The arn i am receiving from output is a object style but not coming as a string as mentioned in pulumi doc.
output is coming in form of
<pulumi.output.Output object at 0x1075c4430>
but not actual a string.
so arn is an
, 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 minutes
I am not sure how apply works here, if you can guide me over it. Sure take your time.
this is a very simple example
Copy code
def write_to_file(arn):
    f = open("arn.txt", "a")

# 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))
so you want to run the function
only after the actual resource has been created and the API has returned a value to you. That's what apply does
this video is for nodejs, but the Pulumi principles remain the same


btw it's very very common for people not to grok this, so it's not surprising
Oh that looks absolutely interesting, let me try this way if it works.
I've found that a useful way to think about it is, your code is creating a "deployment plan".. So any "regular" Python code in the sequential flow of the program runs before deployment, and can really only provide input to the deployment steps, not act on output.
As @billowy-army-68599 said, when you have an Output you want to act on, like
, you have to pass your action as a lambda that Pulumi can run once the resource referenced by the Output has been deployed / updated.