Hi all, Could somebody please advise what would be...
# python
w
Hi all, Could somebody please advise what would be the best way to read a secret from the pulumi config file and print it or write it in a file when executing the pulumi main.py?
Here’s the code I am trying with:
Copy code
secret_config = pulumi.Config()
opensearch_secret = secret_config.get_secret('opensearch_master_user_password')

def get_secret_value(decrypted_value: str):
    return decrypted_value


render_helmfile_template(HELMFILE_SECRETS_YAML, 
                            {'registry_password': 'some-value', 
                            'registry_host': 'some-value', 
                            'registry_user': 'some-value'),
                            'opensearch_password': opensearch_secret.apply(get_secret_value),
                            'postgres_password': 'some-value',
                            'keycloak_password': 'some-value'},
                            'secrets.yaml')
But that doesn’t work. I am getting the following in the generated file.
Copy code
## -- Secrets of OpenSearch
opensearch:
  external:
    password: Calling __str__ on an Output[T] is not supported.

To get the value of an Output[T] as an Output[str] consider:
1. o.apply(lambda v: f"prefix{v}suffix")

See <https://www.pulumi.com/docs/concepts/inputs-outputs> for more details.
This function may throw in a future version of Pulumi.
a
You can write files by doing so in a callback/lambda passed to
.apply
on a single output or use
pulumi.Output.all
if you have to await many outputs. See some examples here: https://gist.github.com/olafurnielsen/c5bb06492e5456761e7fec584718a4a6
w
Thank you @adventurous-butcher-54166