is there a way I can debug python starlark ? ipyth...
# python
b
is there a way I can debug python starlark ? ipython for example or any remote debugging? I would like to know why
dns_name
of
pulumi_gcp.dns.ManagedZone
is class
pulumi.output.Output
and how to convert it to
str()
so I can use it later
l
I'd start by reading about Inputs, Outputs, and .Apply() https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs
(this does not answer your debugging question but is important to understand when working with pulumi)
Fundamentally, working with the cloud is asynchronous. Many of these values that you see as
Output
are not known at runtime. They become eventually available as cloud resources are created. Because of this, you need to use
.Apply()
to execute callbacks when those resources become available.
.Apply()
creates a new asynchronous future that can be passed as input to another cloud resource. For instance you can create a VPC, and it will have a subnetID output that can be passed as input to create an EC2 instance or virtual machine.
❤️ 1
b
hmm but is there a terminal where I can see the output for debugging? I'm missing
terraform console
or
ipython
? Here is good ex: lets say I have this decliration `
Copy code
b81_zone = dns.ManagedZone("b81-root", description="Root of b81.dev", dns_name="b81.dev.", labels={"managed_by": "pulumi"})
and I want to use
b81_zone.dns_name
but I simply can't get it 😞 The closest that I got is `
Copy code
b81_zone.dns_name.apply(lambda dns_name: dns_name)
but it still returns Output class. I just need a terminal or a way to debug this class
l
What do you want to use it for? Do you want to consume it from outside the program? If so you can use a stack output https://www.pulumi.com/docs/intro/concepts/programming-model/#stack-outputs
You can also do print statements from within
.Apply
calls.
b
now I feel dumb because I can't print simple attribute 😞 `
Copy code
print(b81_zone.dns_name.apply(lambda foo: f"{foo}"))
is not working 😞
ok, now I get it 😞
b81_zone.dns_name.apply(lambda c: print(c))