AWS Cloudformation Stringlist错误

时间:2018-03-16 05:06:04

标签: amazon-web-services amazon-cloudfront amazon-cloudformation

错误:属性验证失败:[属性值{/ StreamingDistributionConfig / TrustedSigners / AwsAccountNumbers}与类型{Array}不匹配。

我正在尝试在名为awsAccountNumbers的参数中获取多个帐户ID,对于该参数,cloudformation文档说此参数必须是StringList类型。但是,没有这种类型。我们在AWS参数参考中有字符串 CommaDelimitedList ,我得到了上述错误。我也试过拆分它,但没有帮助。请在下面找到我的代码:

**Parameters Section:** 
  "awsAccountNumbers": {
            "Type": "String",

  }

**Resources Section:** 

   "TrustedSigners": {
                        "AwsAccountNumbers": {
                            "Fn::If": [
                                "withRestrictViewerAccessasYes",
                                {
                                    "Fn::If": [
                                        "withTrustedSignersasSelf",
                                        "882410330966",
                                        [
                                            {
                                                "Fn::Select": [
                                                    "0",
                                                    {
                                                        "Fn::Split": [
                                                            ",",

                                                            { "Ref": "awsAccountNumbers" }

                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    ]
                                },
                                {
                                    "Ref": "AWS::NoValue"
                                }
                            ]
                        },
                        "Enabled": {
                            "Ref": "trustedSignersEnabled"
                        }
                    }

1 个答案:

答案 0 :(得分:0)

我猜错误指的是实际属性(AwsAccountNumbers)而不是参数(awsAccountNumbers)。

AwsAccountNumbers需要一份清单。它应该是下面的(未经测试的)

"Parameters" : {
  "awsAccountNumbers": {
    "Type": "CommaDelimitedList",
     "Default": "882410330966, 882410330966, 882410330966"
  }

{
    "TrustedSigners": {
        "AwsAccountNumbers": [{
            "Fn::If": [
                "withRestrictViewerAccessasYes",
                {
                    "Fn::If": [
                        "withTrustedSignersasSelf",
                        "882410330966", [{
                            "Fn::Select": [
                                "0",
                                {
                                    "Ref": "awsAccountNumbers"
                                }
                            ]
                        }]
                    ]
                },
                {
                    "Ref": "AWS::NoValue"
                }
            ]
        }],
        "Enabled": {
            "Ref": "trustedSignersEnabled"
        }
    }
}