cfn2ts: some property types are parsed as interfaces instead of structs
See original GitHub issueUsing the python cdk, attempting to create a Web ACL with an IP whitelisting rule, but found that creating Web ACL rule properties does not work when trying to define an IP Set. I receive an error stating:
TypeError: Protocols cannot be instantiated
Reproduction Steps
# Working rule prop, with aws managed rule group
rule_sql = wafv2.CfnWebACL.RuleProperty(
name='AWS-AWSManagedRulesSQLRuleSet',
statement=wafv2.CfnWebACL.StatementOneProperty(
managed_rule_group_statement=wafv2.CfnWebACL.ManagedRuleGroupStatementProperty(
vendor_name='AWS',
name='AWSManagedRulesSQLRuleSet'
)
),
visibility_config=wafv2.CfnWebACL.VisibilityConfigProperty(
sampled_requests_enabled=True,
cloud_watch_metrics_enabled=True,
metric_name='AWS-AWSManagedRulesSQLRuleSet'
),
priority=0,
)
# Non-working rule prop, with IP set reference
rule_ip = wafv2.CfnWebACL.RuleProperty(
name='IPRule',
statement=wafv2.CfnWebACL.StatementOneProperty(
ip_set_reference_statement=wafv2.CfnWebACL.IPSetReferenceStatementProperty(
arn='myArn'
)
),
visibility_config=wafv2.CfnWebACL.VisibilityConfigProperty(
sampled_requests_enabled=True,
cloud_watch_metrics_enabled=True,
metric_name='IPRule'
),
priority=0,
)
Error Log
When synthing templates, this error is received:
File “…\infra\cdk.env\lib\site-packages\jsii_runtime.py”, line 66, in call inst = super().call(*args, **kwargs) File “…\infra\cdk\stacks\stacks_lib\static_site_hosting.py”, line 56, in init arn=‘myArn’ File “…\infra\cdk.env\lib\site-packages\typing_extensions.py”, line 1545, in _no_init raise TypeError(‘Protocols cannot be instantiated’) TypeError: Protocols cannot be instantiated
Environment
- CLI Version :
- Framework Version: 1.27
- OS : Windows
- Language : Python
Other
Linked somewhat to: https://github.com/aws/aws-cdk/issues/6056
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:20 (4 by maintainers)
Top GitHub Comments
As a workaround, I was able to implement the IPSetReferenceStatementProperty interface myself in python like so:
And then reference that new class instead:
At which point, I am able to CDK synth the template, and it captures the proper reference to the IP Set Reference Statement.
Was bitten by this today, thanks a lot @KyleMuellerPFG!