How to reference auto-named Pulumi resources in tests?TypeScript
Sure, while testing Pulumi programs, you can use the
getOutputmethod for referencing auto-named Pulumi resources.
Let's say you have a bucket resource with an autogenerated name:
To reference this S3 bucket in your tests, obtain the bucket name using
The apply function is used here to interact directly with the output's value (the bucket name).
getOutputmethod returns a value of type
Output, which represents a value that is computed asynchronously (i.e., an output property value or a resource output property value computed during a Pulumi preview or update).
Keep in mind that this isn't used during the unit testing phrase but is helpful during integration testing where the actual resources are being used.
For more details, refer to the official Pulumi testing guide.