https://pulumi.com logo
#general
Title
# general
p

plain-businessperson-30883

10/08/2019, 5:22 PM
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

quaint-teacher-33292

10/08/2019, 5:25 PM
I think this works:
Copy code
$ pulumi stack -i | grep cloudflare
    kubernetes:core/v1:Secret                                                       cloudflare-account
        ID: default/cloudflare-account-3o9j4opj
p

plain-businessperson-30883

10/08/2019, 5:44 PM
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

quaint-teacher-33292

10/08/2019, 5:46 PM
You can also export stuff programmatically with stack outputs, it's easy retrieving them later
p

plain-businessperson-30883

10/08/2019, 5:53 PM
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

stocky-island-3676

10/09/2019, 5:36 PM
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

plain-businessperson-30883

10/09/2019, 9:33 PM
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!