https://pulumi.com logo
#automation-api
Title
# automation-api
c

curved-quill-94238

02/22/2022, 3:39 PM
Does anyone know how to access values in the stack's
config
from inside an inline program (Python flavor)? I feel like there must be a way to do this, but I haven't found it in the docs, examples, or Stack Overflow I tried
pulumi.get_stack()
to see if I could then run
get_config
, but apparently
get_stack
returns just the
str
of the stack name, not the actual
Stack
object itself
ah, is it
pulumi.runtime.get_config
? seems like it might be
b

bland-continent-32037

02/22/2022, 10:37 PM
pulumi config
has get functionality, and it's accessible programmatically. It looks like this:
Copy code
config = pulumi.Config();
name = config.require('name');
lucky = config.get_int('lucky') or 42
print(f'Hello, {name} -- I see your lucky number is {lucky}!')
1
Here's the docs for more detailed info 😄 https://www.pulumi.com/docs/intro/concepts/config/
c

curved-quill-94238

02/23/2022, 4:44 PM
Thanks for the info. But I get an error when trying to use that inside the inline program
PulumiFn
that I don't get when using
pulumi.runtime.get_config
Copy code
error: an unhandled error occurred: Missing required configuration variable 'iac-demo:proj:aws_account_id'
    please set a value using the command `pulumi config set iac-demo:proj:aws_account_id <value>`
62 Views