Open anentropic opened 9 months ago
I can get past it by supplying:
restrictions=aws.cloudfront.DistributionRestrictionsArgs(
geo_restriction=aws.cloudfront.DistributionRestrictionsGeoRestrictionArgs(
restriction_type="none",
)
),
but then I hit the next error:
cloudfront/distribution.py", line 1496, in _internal_init
raise TypeError("Missing required property 'viewer_certificate'")
TypeError: Missing required property 'viewer_certificate'
...so it looks like there's a bunch of properties typed as optional which are really required
or maybe there's some missing/broken code that is supposed to transform the default None
values into the more fully specified default value expected by the underlying provider
FWIW it seems like this field is required in the underlying terraform provider https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#restrictions
Hi @anentropic. I understand your confusion. In Pulumi's python SDKs, there are 2 ways to pass arguments to a resource.
Directly to the resource constructor:
Distribution(name, restrictions=your_restrictions)
Via a resource args bundle:
Distribution(name, args=DistributionArgs(restrictions=your_restrictions))
It seems like we only have correct Optional
typing for the Args
variant. I'll pass this feedback to our codegen team.
hmm I can see now that there are four relevant type signatures
you're already using @overload
to provide the alternative call styles for Distribution.__init__
so there's:
args
object overload form ... this is the one where I'd like to see the types of individual args like restrictions
reflect whether they are actually required or not (currently all typed as optional)args
object overload form where no individual args should be passed*args
and **kwargs
, seems fine_internal_init
called from __init__
which doesn't have an @overload
and all args are typed as optional, seems finehopefully this is possible to fix and is not a result of some limitation in the Python type checkers... thanks for looking :)
What happened?
I have a Python 3.11 project using pulumi-aws==6.17.0
when creating a cloudfront distribution the type annotation on the
Distribution
resource in pulumi has:but if I omit this arg, or pass
restrictions=None
, I get an error when Ipulumi up
the stack:so it seems like this field is not actually optional
Example
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).