great-sunset-355
06/23/2021, 9:51 AMpulumi config set-all --path \
--secret passwords.pw1=Secret
How do I call this in the code? I cannot see to wrap my head around strange paths in the yaml file
cfg = pulumi.Config()
# Neither of these worked:
cfg.require_secret('passwords.pw1')
cfg.require_secret('["passwords"].["pw1"]') # does not work
billowy-army-68599
06/23/2021, 9:55 AMpasswordConfig = pulumi.Config("passwords")
passwordConfig.require_secret("pw1")
I think is what you need (untested)great-sunset-355
06/23/2021, 10:03 AMno it id not work I got an error please set a value using the command `pulumi config set passwords:pw1 <value>`
billowy-army-68599
06/23/2021, 10:23 AMgreat-sunset-355
06/23/2021, 10:25 AMbillowy-army-68599
06/23/2021, 10:29 AMconfig = pulumi.Config()
passwords = config.require_object("passwords")
pw = passwords.get("pw1")
<http://pulumi.log.info|pulumi.log.info>(pw)
require_secret_object
great-sunset-355
06/23/2021, 10:29 AMbillowy-army-68599
06/23/2021, 10:30 AMgreat-sunset-355
06/23/2021, 10:31 AMsecret object
contains mix of secret and not secret values, all of them are treated as secretsbillowy-army-68599
06/23/2021, 10:35 AMgreat-sunset-355
06/23/2021, 10:41 AMfrom dataclasses import dataclass
import pulumi
@dataclass
class MyConfig:
pw1: Any
config = pulumi.Config()
passwords = config.require_secret_object("passwords")
mycfg = MyConfig(passwords['pw1'])
print(mycfg)
However this does not:
from dataclasses import dataclass
import pulumi
@dataclass
class MyConfig:
pw1: Any
config = pulumi.Config()
passwords = config.require_secret_object("passwords")
mycfg = MyConfig(**passwords)
print(mycfg)
with error
TypeError: attribute of type 'Output' is not callable
error: an unhandled error occurred: Program exited with non-zero exit code: 1
I wonder if there is a way to get the keys
from the Output without knowing thembillowy-army-68599
06/23/2021, 10:42 AMgreat-sunset-355
06/23/2021, 10:43 AMbillowy-army-68599
06/23/2021, 12:49 PMapply
because it's an outputgreat-sunset-355
06/23/2021, 12:49 PMconfig:
NS:obj:
ALLOWED_HOSTS:
- <http://URL1.com|URL1.com>
- <http://URL2.com|URL2.com>
I'm trying to construct call ','.join(ALLOWED_HOSTS)
as an string input for another resource
And since my ALLOWED_HOSTS is part of a secret object it is not possible even with apply I keep getting `Output`s never the valuebillowy-army-68599
06/23/2021, 12:50 PMgreat-sunset-355
06/23/2021, 12:54 PMbillowy-army-68599
06/23/2021, 12:56 PMgreat-sunset-355
06/23/2021, 12:56 PMbillowy-army-68599
06/23/2021, 1:06 PMconfig = pulumi.Config()
foo = config.require_object("foo")
allowed_hosts = foo.get("allowed_hosts")
print(type(allowed_hosts))
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[0])
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[1])
If you want it as a secret object:
config = pulumi.Config()
foo = config.require_object("foo")
secret_foo = config.require_secret_object("foo")
allowed_hosts = foo.get("allowed_hosts")
secret_allowed_hosts = foo.get("allowed_hosts")
print(type(allowed_hosts))
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[0])
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[1])
<http://pulumi.log.info|pulumi.log.info>(secret_allowed_hosts[2])
secret_foo.apply(lambda host: print(host))
Type Name Plan Info
+ pulumi:pulumi:Stack py-structured-config-dev create 5 messages
Diagnostics:
pulumi:pulumi:Stack (py-structured-config-dev):
<class 'list'>
{'allowed_hosts': ['<http://example.com|example.com>', '<http://example.net|example.net>', '[secret]']}
<http://example.com|example.com>
<http://example.net|example.net>
[secret]
Do you want to perform this update? [Use arrows to move, enter to select, type to filter]
yes
> no
details
great-sunset-355
06/23/2021, 1:15 PMsecret_allowed_hosts = foo.get("allowed_hosts")
billowy-army-68599
06/23/2021, 1:19 PMimport pulumi
config = pulumi.Config()
foo = config.require_object("foo")
secret_foo = config.require_secret_object("foo")
allowed_hosts = foo.get("allowed_hosts")
secret_allowed_hosts = secret_foo.apply(lambda h: print(h.get("allowed_hosts")))
print(type(allowed_hosts))
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[0])
<http://pulumi.log.info|pulumi.log.info>(allowed_hosts[1])
<http://pulumi.log.info|pulumi.log.info>(secret_allowed_hosts[2])
secret_foo.apply(lambda host: print(host))
great-sunset-355
06/23/2021, 1:24 PMbillowy-army-68599
06/23/2021, 1:28 PMgreat-sunset-355
06/23/2021, 1:29 PMbillowy-army-68599
06/23/2021, 1:35 PMgreat-sunset-355
06/23/2021, 1:47 PMbillowy-army-68599
06/23/2021, 1:54 PMgreat-sunset-355
06/23/2021, 1:54 PMpulumi config set-all --path \
--plaintext foo.allowed_hosts[0]=host1 \
--plaintext foo.allowed_hosts[1]=host2
billowy-army-68599
06/23/2021, 2:35 PMneed_list
method won't work either, because you're trying to do a join on an async valuegreat-sunset-355
06/23/2021, 3:53 PMbillowy-army-68599
06/23/2021, 3:54 PMapply
great-sunset-355
06/23/2021, 4:11 PMbillowy-army-68599
06/23/2021, 4:14 PMgreat-sunset-355
06/23/2021, 8:27 PMwait_for_loadbalancer
it does not wait for the function