https://pulumi.com logo
#golang
Title
g

green-musician-49057

05/18/2021, 3:47 PM
Is there an example of wrapping strings as
pulumi.Secret
in golang? Do we have to use ApplyT to get convert the output to the right type?
g

gentle-diamond-70147

05/18/2021, 4:23 PM
Can you elaborate on what you're trying to do?
You can use
pulumi.ToSecret(value)
to wrap a string as secret - https://www.pulumi.com/docs/intro/concepts/secrets/#programmatically-creating-secrets.
g

green-musician-49057

05/18/2021, 5:05 PM
Yeah, a couple of things: 1. Pass a secret obtained from an environment variable into a cloudformation resource as a cloudformation stack parameter. Currently passing this straight through without letting pulumi know it's a secret, b/c the type for
Parameters
is
pulumi.StringMapInput
2. Passing that same secret into a aws.secretsversion secretstring, via something like the key-value pairs example here https://www.pulumi.com/docs/reference/pkg/aws/secretsmanager/secretversion/#key-value-pairs (We're migrating away from cloudformation and envvars, I swear 😅 )
It's not obvious if it is worth converting that envvar secret to a pulumi secret for either of those cases to begin with. We're not printing anything to stdout, but I would rather not have it accidentally leak in case of a panic/error
g

gentle-diamond-70147

05/18/2021, 6:46 PM
I'm not entirely sure I'm following your points, but here's an example that I think describes what you're wanting. Does this answer your question?
g

green-musician-49057

05/18/2021, 6:58 PM
myVarSecret.(pulumi.StringOutput)
That's the missing piece of the puzzle that I was looking for!! Thank you
👍 1
3 Views