Does anyone know how to retrieve the token from a ...
# general
p
Does anyone know how to retrieve the token from a freshly created ServiceAccount in Pulumi? Since the secret name of the token is dynamic, I'm not very sure on how to retrieve it in Pulumi.
q
I think this works:
Copy code
$ pulumi stack -i | grep cloudflare
    kubernetes:core/v1:Secret                                                       cloudflare-account
        ID: default/cloudflare-account-3o9j4opj
p
This does not seem to be the ServiceAccount token. Also, I need to get it programmatically, I want to avoid any manual intervention (and avoiding calling the shell would be great too hahaha)
q
You can also export stuff programmatically with stack outputs, it's easy retrieving them later
p
But the resource is not maintained by Pulumi. When I create a ServiceAccount
foo
, it will generate a token secret (e.g.
foo-token-738j4
), with a random suffix. That's what I'd like to retrieve.
s
Hi @plain-businessperson-30883, see the code snippet I posted in this thread (or my Stackoverflow answer over there 🙂 ): https://pulumi-community.slack.com/archives/CJ909TL6P/p1567790791008100
p
I ended up noticing (thanks @cool-egg-852) that the
ServiceAccount
instance has a
secrets
property that gets populated with its token's secret name, from where I could perform the
k8s.core.v1.Secret.get()
. Thanks you all for the help!