How can I properly populate the readme? I am follo...
# aws
s
How can I properly populate the readme? I am following (https://www.pulumi.com/docs/pulumi-cloud/projects-and-stacks/?_ga=2.149016052.318359768.1694094860-180507132.1691596035#stack-readme).
Copy code
import pulumi
from pulumi_aws_native import s3

# Create an AWS resource (S3 Bucket)
bucket = s3.Bucket("my_bucket")

pulumi.export("my_bucket", bucket.id)

with open('./Pulumi.README.md') as f:
    pulumi.export('readme', f.read())
The readme with contents of:
Copy code
- main bucket ${bucket.id}
- my_bucket ${my_bucket}
The file is neatly uploaded. However, the ${} reference to the variable is never resolved and empty. What do I need to change to get the variables to resolve?
@billowy-army-68599 here the single direct question
b
what are you trying to do? put the bucket id into a readme file?
s
yes
b
you need to wait for the bucket ID to return from the API and then write to the README file, like this:
Copy code
bucket.id.apply(
    # anything that happens inside this apply block happens
    # after the s3 bucket has finished being created
    lambda bucket_id: open("README.md", "w").write(bucket_id)
)
s
https://www.pulumi.com/blog/stack-readme/#step-1 but this is looking so much different here. When I have multiple values having such a xxx.apply.write for each sounds fairly complex
b
@sparse-optician-70334 that is a special
Pulumi.README.md
- they operate differently and render in the Pulumi Cloud interface. Notice the README itself looks like this:
Copy code
# Stack README

Full markdown support! Substitute stack outputs dynamically so that links can depend on your infrastructure! Link to dashboards, logs, metrics, and more.

1. Reference a string stack output: ${outputs.strVar}
2. Reference an array stack output: ${outputs.arrVar[1]}
More info on stack readme’s can be found here: https://www.pulumi.com/blog/stack-readme/ You will see those outputs in the cloud console, not in your regular file. If you just want to populate a regular file, you’ll have to do it the way I explained.
s
understood - indeed I want it in the stack readme. However, also there - the variables are empty and not rendered
b
can you screenshot the cloud console for me?
and show your readme?
s
sure. However, I think I could figure it out now thanks to your help: outputs was missing
many thanks
b
happy to help!
s
thanks - I hope it is fine that I tried to ping you on one more AWS basics question around Output[T]
b
absolutekly