great-sunset-355
08/03/2021, 11:37 AMif 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 conditionscool-fireman-90027
08/03/2021, 12:49 PM"""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.great-sunset-355
08/03/2021, 1:39 PMred-match-15116
08/03/2021, 3:18 PMdef validate_region(region):
if region != "wanted region":
raise ValueError("provider has bad region")
provider.region.apply(validate_region)
great-sunset-355
08/03/2021, 5:02 PMred-match-15116
08/03/2021, 5:08 PMOutput
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.great-sunset-355
08/03/2021, 5:39 PM