has anybody tried to get the current aws region in...
# python
r
has anybody tried to get the current aws region in your code and discovered that you get
None
instead? I’m seeing that at the command line, pulumi has no issues with `pulumi config get aws:region`… so I try to do the same with
config.get('aws:region')
, but for some reason I get
None
(verified using
print()
)
nvm. Just read https://www.pulumi.com/docs/intro/concepts/config/ and realized how this config thing works. You need to create a separate
pulumi.Config()
for
aws:region
f
You can use
pulumi_aws
also:
Copy code
# Set Region
aws_region = str(pulumi_aws.get_region().name)
r
I don't believe you can use
pulumi_aws.get_region()
as an input to another resource. But now I see that there's also
.get_region_output
as well, which may work for what I need the region string for. I'm afk right now, but will definitely try this when i get back
f
I can confirm it works, I’m using the line above in my project
r
thank you! I appreciate it. I just tried it myself, and am able to as well, with just
pulumi_aws.get_region().name
. The crucial bit that was missing for me was the
.name
🤦‍♂️ It looks from https://www.pulumi.com/registry/packages/aws/api-docs/getregion/ that
.name
is already a `str`; you shouldnt need to
str(...)
it