aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.63k stars 3.91k forks source link

(aws_wafv2): Can't synthesize simple WebACL with visibility_config #12933

Closed corvax19 closed 3 years ago

corvax19 commented 3 years ago

Hi,

Can't synthesize stack of simple WebACL with visibility_config specified.

Reproduction Steps

app.py:

#!/usr/bin/env python3

from aws_cdk import core
from aws_cdk import aws_wafv2 as wafv2

app = core.App()
webACL = wafv2.CfnWebACL(app, "WebACL",
    default_action=wafv2.CfnWebACL.DefaultActionProperty.allow,
    scope='REGIONAL',
    visibility_config = wafv2.CfnWebACL.VisibilityConfigProperty(
      metric_name = "MyMetric",
      sampled_requests_enabled = True,
      cloud_watch_metrics_enabled = True
    )
)

cdk.json:

{
  "app": "python3 app.py",
  "versionReporting": false,
  "context": {
      "@aws-cdk/core:enableStackNameDuplicates": "true",
      "aws-cdk:enableDiffNoFail": "true",
      "@aws-cdk/core:stackRelativeExports": "true"
  }
}

What did you expect to happen?

I expect the stack to synthesize without error.

What actually happened?

Synthesize fails with following error:

(venv) corvax19@mbpro15 cdk-waf-bug % cdk synthesize
Traceback (most recent call last):
  File "app.py", line 18, in <module>
    cloud_watch_metrics_enabled = True
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/aws_cdk/aws_wafv2/__init__.py", line 2989, in __init__
    jsii.create(CfnWebACL, self, [scope_, id, props])
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 268, in create
    args=_make_reference_for_native(self, args),
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 141, in _make_reference_for_native
    return [_make_reference_for_native(kernel, i) for i in d]
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 141, in <listcomp>
    return [_make_reference_for_native(kernel, i) for i in d]
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 158, in _make_reference_for_native
    for python_name, jsii_name in mapping.items()
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 158, in <dictcomp>
    for python_name, jsii_name in mapping.items()
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 174, in _make_reference_for_native
    kernel.create(d.__class__, d)
  File "/Users/corvax19/cdk-waf-bug/venv/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 267, in create
    fqn=klass.__jsii_type__ or "Object",
AttributeError: type object 'property' has no attribute '__jsii_type__'
Subprocess exited with error 1

Environment

Other


This is :bug: Bug Report

njlynch commented 3 years ago

Same issue as #7841 (and I suspect #11611).

https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_wafv2/CfnWebACL.html#defaultactionproperty

Change your default_action line to this:

default_action=wafv2.CfnWebACL.DefaultActionProperty(allow={}),

That should solve the issue. If not, please feel free to re-open.

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.