【问题标题】:TestWebACL Error reason: Your statement has multiple values set for a field that requires exactly one valueTestWebACL 错误原因:您的语句为一个字段设置了多个值,而该字段只需要一个值
【发布时间】:2020-12-18 14:00:12
【问题描述】:
 var ipSets = new CfnIPSet(scope, "IPSet", new CfnIPSetProps
            {
              
                Name = "IPTest",
                Addresses = new string[] { "1.2.3.4/32" },
                IpAddressVersion = "IPV4",
                Scope= "REGIONAL"
});

new CfnWebACL.RuleProperty()
                    {
                        Name = "Black-List-Rules",
                        Priority = 5,
                       //statement not properly translated
                        Statement = new CfnWebACL.StatementOneProperty
                        {
                             IpSetReferenceStatement = ipSets.AttrArn
                        },
                        VisibilityConfig = new CfnWebACL.VisibilityConfigProperty
                        {
                            SampledRequestsEnabled = true,
                            CloudWatchMetricsEnabled = true,
                            MetricName = "Black-List-Rules"
                        },
                        Action = new CfnWebACL.RuleActionProperty
                        {
                            Allow = new CfnWebACL.RuleActionProperty { Allow = false}
                        },
 }

TestWebACL 错误原因:您的语句为一个字段设置了多个值,该字段只需要一个值。,字段:STATEMENT,参数:Statement(服务:Wafv2,状态代码:400,请求 ID:dd0d6492-5aa9-41e2-ac15 -ee7bc133d705,扩展请求 ID:空) C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:49 _ Kernel._wrapSandboxCode (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:8395:20) _ Kernel._create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7922:26) _ Kernel.create (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7666:21) _ KernelHost.processRequest (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7446:28) _ KernelHost.run (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7384:14) _ Immediate._onImmediate (C:\Users\futechz\AppData\Local\Temp\1hae5afq.wun\jsii-runtime.js:7387:37) _ processImmediate (internal/timers.js:456:21)

云形成(cdk 合成器)

{
            "Action": {
              "Block": {
                "block": true
              }
            },
            "Name": "Black-List-Rules",
            "Priority": 5,
            "Statement": {}, //missing
            "VisibilityConfig": {
              "CloudWatchMetricsEnabled": true,
              "MetricName": "Black-List-Rules",
              "SampledRequestsEnabled": true
            }
          }

【问题讨论】:

    标签: c# amazon-web-services amazon-cloudformation aws-cdk


    【解决方案1】:

    解决了

     ["Statement"] = new Dictionary<string, object>
                            {
                                ["OrStatement"] =   new Dictionary<string, object>
                                {
                                    ["Statements"] = new [] {
    
                                            new Dictionary<string, object>
                                            {
                                                ["IpSetReferenceStatement"] = new Dictionary<string , object> {
                                                       ["Arn"] = ipSetsOne.AttrArn
                                                },
                                            },
                                            new Dictionary<string, object>
                                            {
                                                ["IpSetReferenceStatement"] = new Dictionary<string , object> {
                                                       ["Arn"] = ipSetsTwo.AttrArn
                                                },
                                            }
    
                                    }
    
                                }
    
                            },
    

    https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html

    【讨论】:

    • 这对我不起作用。你能把整个剪辑贴出来吗?
    • github.com/aws/aws-cdk/issues/10058 似乎是同一张海报,但两个答案都不完整(你不能简单地将 Statement 属性替换为 ["Statement"] 块并让它工作)
    猜你喜欢
    • 2019-05-06
    • 2023-02-06
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 2015-04-09
    • 2022-08-08
    • 1970-01-01
    • 2018-02-07
    相关资源
    最近更新 更多