-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
cfn2ts: some property types are parsed as interfaces instead of structs #6643
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. |
Ha! Because of JSII naming conventions, Our |
In fact it should be an error if any of the L1 generators generate any class that JSII will interpret as an interface. It should be all classes and structs, no? |
Here is the code from cdk8s that normalizes the IXXXFoo type names: |
Since I'm still having issues with #6056, could this be related? |
I am also facing this issue with error message TypeError: Protocols cannot be instantiated when using ipset_reference_statement=waf.CfnRuleGroup.IPSetReferenceStatementProperty(arn="arn:XXXXXXXXX". |
Thanks @KyleMuellerPFG - this enabled me to get an IP set working! If anyone else finds this issue, note too that your IP rule can't contain the override_action parameter, or you'll get the error "Error reason: Your statement has multiple values set for a field that requires exactly one value., field: RULE," - because this is only valid for statements that refer to rule groups. |
Just saw your fix. Where did you implement the workaround. Not sure where you make the code modification in CDK? I ran into the same issue today. Thanks for posting. |
Was bitten by this today, thanks a lot @KyleMuellerPFG! |
Same here, wasted a lot of time on this. I thought CFN L1 structs were as good as cloudformation. Please get this fix in. Big thanks as well @KyleMuellerPFG |
Hi, same issue here, it took a lot of time to get here, please fix this, thanks so much @KyleMuellerPFG |
See also #14445, where this was reported in Java as well. |
with aws_cdk 1.104.0, the "fix" doesnt work any more. I am getting this error: |
This worked fine in 1.107.0! |
I also thought L1 constructs were a 1-1 mapping with Cloudformation :( Is anyone aware of a list of other properties that might need similar workaround? |
I'm facing this issue also with CfnIPSet.IPSetDescriptorProperty in CDK V2rc25 |
I was using the workaround mentioned above by Kyle but it stopped working after I upgraded to CDK 2.5.0. As advised by AWS support, the following works in my case: ip_set_v4 = wafv2.CfnIPSet(
scope,
'IPSetv4',
addresses=Configuration.waf_ipsets,
ip_address_version='IPV4',
scope=WafProvisioner.__SCOPE_CLOUDFRONT,
)
# ...
web_acl = wafv2.CfnWebACL(
# ...
rules=[
wafv2.CfnWebACL.RuleProperty(
# ...
statement=wafv2.CfnWebACL.StatementProperty(
ip_set_reference_statement={
"arn": ip_set_v4.attr_arn
}
),
), |
Can you give a little more info on how that is suppose to be implemented. Maybe some comments on the lines that are specific to your environment? |
I get this error when I try @charlesxucheng 's solution. |
Hi @WingsLikeEagles. Yes 'IPSetv4' is the id of the construct. waf_ipsets is an array of strings of CIDR ranges you want to attach to the rule. |
It looks like this issue was fixed by upgrading to >2.5.0. I'm going to go ahead and close this one. If you believe this was closed in error or are using this version or above and are still experiencing this issue, please open a new issue. |
|
Using 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
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
Other
Linked somewhat to: #6056
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: