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

powerful-lighter-63321

11/30/2023, 11:09 AM
I want to use also the python-gitlab within my project. Therefore I also want to access gitlab::token from the secrets. I try to avoid duplication of the config entries. Within my code I tried to:
Copy code
config = pulumi.Config()
gitlab_password = config.require_secret("gitlab::token")
But this causes the error:
Diagnostics:
pulumi:pulumi:Stack (projects-main):
error: Missing required configuration variable 'projects:gitlab::token'
`please set a value using the command `pulumi config set --secret projectsgitlab:token <value>``
error: an unhandled error occurred: program exited with non-zero exit code: 1
This might be true, because I didn't have projectsgitlab:token, but gitlab::token. How do I get this secret from the configs in my code?
l

limited-rainbow-51650

11/30/2023, 2:57 PM
@powerful-lighter-63321 in
gitlab:token
, the first part is the namespace. When you want to read the
token
secret in your code, you create a
Config
object on the correct namespace first:
Copy code
gitlabConfig = pulumi.Config("gitlab")
gitlab_password = gitlabConfig.require_secret("token")
Side note:
gitlab::token
(2 colons) is not valid. It should be
gitlab:token
(1 colon).
p

powerful-lighter-63321

12/01/2023, 6:28 AM
Thanks for your help. It works, but after trying it, I decided to avoid the whole pulumi-secret part for me. I'll go with the environment-variables. I can use them within the "normal" and in the "pulumi" code. Which is obviously a benefit. I see the advantages with the "apply" stuff, but in case of the "secrets" and "configs" they're definitively a huge burden. So to keep code simple.. I use Environment variables. 😄