Does anyone know how to access values in the stack...
# automation-api
c
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
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
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>`