Search code examples
c#.netamazon-web-servicesaws-cdkamazon-waf

How can I set value to CfnWebACL.DefaultActionProperty.Allow property in WAFv2 from AWS CDK and .NET core


I'm trying to create WAFv2 WebAcl service using AWS CDK. My programming language is C# (.NET Core). I'm not able to figure out how to set value of CfnWebACL.DefaultActionProperty.Allow or CfnWebACL.DefaultActionProperty.Block property as it is an object type and any value I assign to it result in runtime error.


Solution

  •  new CfnWebACL(this, "webacl", new CfnWebACLProps
    {
                DefaultAction = new CfnWebACL.DefaultActionProperty
                {
                    Allow = new CfnWebACL.RuleActionProperty() { Allow = true }
                },
                ...
    });
    

    This model type seems to work for me ^