https://pulumi.com logo
#aws
Title
# aws
s

sparse-optician-70334

09/12/2023, 7:25 AM
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

billowy-army-68599

09/12/2023, 2:10 PM
what are you trying to do? put the bucket id into a readme file?
s

sparse-optician-70334

09/12/2023, 2:10 PM
yes
b

billowy-army-68599

09/12/2023, 2:13 PM
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

sparse-optician-70334

09/12/2023, 2:19 PM
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

billowy-army-68599

09/12/2023, 2:36 PM
@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

sparse-optician-70334

09/12/2023, 2:47 PM
understood - indeed I want it in the stack readme. However, also there - the variables are empty and not rendered
b

billowy-army-68599

09/12/2023, 2:53 PM
can you screenshot the cloud console for me?
and show your readme?
s

sparse-optician-70334

09/12/2023, 2:56 PM
sure. However, I think I could figure it out now thanks to your help: outputs was missing
many thanks
b

billowy-army-68599

09/12/2023, 2:57 PM
happy to help!
s

sparse-optician-70334

09/12/2023, 3:01 PM
thanks - I hope it is fine that I tried to ping you on one more AWS basics question around Output[T]
b

billowy-army-68599

09/12/2023, 3:02 PM
absolutekly
2 Views