-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for conditionals inside properties #668
Comments
Good issue to bring up. In general this should not be an issue with just troposphere. The "If" class is derived from AWSHelperFn and there is specific code in BaseAWSObject::setattr() which allows these AWSHelperFn to be used instead of the normal validation. I think you're seeing an issue due to awacs and troposphere being separate projects (yeah, in hindsight I might have just made them one project). I'd have to look harder at your specific example to see if there is a good workaround. |
Thanks! To get the JSON generated I modified the aws.Policy object definition, changed
to
which is obviously not ideal, but got the template I needed. |
Another example. When try to use the TemplateGenerator to read the following CFT which contains the following S3 Bucket resource which has a condition on MetricsConfiguration , an AssertionError occurs:
|
Conditionals like IF can be used inside some properties, but because of strict type checking, troposphere does not allow for their use.
For example, the following is a correct template snippet (not a specific use-case I had, just an example):
which should have a representation in troposphere as below:
but it obviously fails with
TypeError: Statement is <class 'troposphere.If'>, expected [<class 'awacs.aws.Statement'>]
This specific example is related to awacs, but I imagine the same problems happen directly in troposphere as well, wherever the property is expected to be a specific object.
Should conditionals be allowed by troposphere inside most (all?) properties? Either via something simple to how
policytypes
are solved iniam
or by something more complex which will detect the condition and check for the types inside the condition?The text was updated successfully, but these errors were encountered: