How can I get default provider object so I can use...
# aws
How can I get default provider object so I can use it as a parameter in a function? how can I do this?
Copy code
if provider.region != "wanted region":
   raise ValueError("provider has bad region")
I cannot write a statement above because it's an Output again and there is no way I know to test output for conditions
"“”An AWS Python Pulumi program”“” You can do something like the following:
Copy code
"""An AWS Python Pulumi program"""

import pulumi
import pulumi_aws as aws

# Create an AWS resource (S3 Bucket)
awsConfig = pulumi.Config("aws")
awsRegion = awsConfig.get("region")

if  awsRegion != "us-east-2":
  raise ValueError("provider has bad region")

pulumi.export("aws_region_selected", awsRegion)
Here are the aws provider inputs You can test it out by changing the region to and then it will throw the error:
pulumi config set aws:region us-east-1
If you set it back to
pulumi config set aws:region us-east-2
- no error will be thrown.
that's evaluating values of the config not the actual provider
Copy code
def validate_region(region):
    if region != "wanted region":
        raise ValueError("provider has bad region")

Oh wait… the default provider. I’m not sure you can get the default provider (but it uses the default region declared in your config so what @cool-fireman-90027 wrote will get you the same information). If you need to do something with the provider you should explicitly declare a provider resource in your code. But as far as your question about how to validate outputs, the code I wrote should be applicable for all outputs.
okay thank you, it seems it's also limited to apply scope again 😞 about default provider - since the best practice is to declare your provider directly, would be better to disable default providers entirely? I noticed in some threads here people having problems when migrating away from default provider to declared one
Yes, the resolved value of an
is only available within an apply. That is the pulumi programming model. Re: disabling default providers is tracked in this issue - feel free to upvote or comment with your input.
Oh that's great to hear! Thank you!