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

careful-market-30508

02/05/2020, 11:10 PM
pretty print pulumi.output - At present pprint(vars(server_object)) produces
Copy code
'address': <pulumi.output.Output object at 0x10f923a58>,
     'allocated_storage': <pulumi.output.Output object at 0x10f8fc048>,
     'allow_major_version_upgrade': <pulumi.output.Output object at 0x10f8fc128>,
     'apply_immediately': <pulumi.output.Output object at 0x10f8fc978>,
     'arn': <pulumi.output.Output object at 0x10f923b00>,
What is the best way to convert entire object to string and print it e.g., the output of server_object = aws.rds.Instance(name,...
I understand I can do something like :
Copy code
url = Output.all([server.username, server.password]).apply(lambda l: f"http://{l[0]}:{l[1]}/")
But Is there a way to dump the whole server object and its fields?
g

gorgeous-egg-16927

02/05/2020, 11:27 PM
You should be able to print the object inside the apply. Something along the lines of
Copy code
url = server_object.apply(lambda l: pprint(vars(l)))
Alternatively, you can view the state of your resources through the pulumi SaaS, or with
pulumi stack export
c

careful-market-30508

02/05/2020, 11:32 PM
AttributeError: 'Instance' object has no attribute 'apply'   error: an unhandled error occurred: Program exited with non-zero exit code: 1
btw- does it work in the preview ?
may be i will pulumi.export("SERVER", server_object) and see it at the end ?
g

gorgeous-egg-16927

02/06/2020, 12:39 AM
Ah, in that case, you need to wrap the object in an output before running apply:
pulumi.Output(server_object).apply(...)
It may not work during preview, as some of the values may not have been resolved yet. The export should also work.
2 Views