【问题标题】:Cloudformation Property validation failure: Encountered unsupported propertiesCloudformation 属性验证失败:遇到不受支持的属性
【发布时间】:2025-11-21 12:55:01
【问题描述】:

我正在尝试创建一个嵌套堆栈,其根堆栈如下所示:

{
    "AWSTemplateFormatVersion": "2010-09-09",

    "Resources": {
        "DynamoDBTable": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "TableName": {
                        "Fn::Sub": "${AWS::StackName}"
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/dynamodb.json"
            }
        },
        "S3WebsiteReact": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "BucketName": {
                        "Fn::Sub": "${AWS::StackName}-website"
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/s3-static-website-react.json"
            }
        },
        "S3UploadBucket": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "BucketName": {
                        "Fn::Sub": "${AWS::StackName}-upload"
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/s3-with-cors.json"
            }
        },
        "Cognito": {
            "Type": "AWS::CloudFormation::Stack",
            "DependsOn": "DynamoDBTable",
            "Properties": {
                "Parameters": {
                    "CognitoUserPoolName": {
                        "Fn::Join" : ["",
                            {
                                "Fn::Split": ["-", {
                                    "Ref": "AWS::StackName"
                                }]
                            }
                        ]
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/cognito.json"
            }
        },
        "ApiGateway": {
            "Type": "AWS::CloudFormation::Stack",
            "DependsOn": ["DynamoDBTable", "Cognito"],
            "Properties": {
                "Parameters": {
                    "ApiGatewayName": {
                        "Fn::Sub": "${AWS::StackName}-api"
                    },
                    "CognitoUserPoolArn": {
                        "Fn::GetAtt": [ "Cognito", "Outputs.UserPoolArn" ]
                    },
                    "DynamoDBStack": {
                        "Fn::GetAtt": [ "DynamoDBTable", "Outputs.DDBStackName" ]
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/api-gateway.json"
            }
        },
        "IdentityPool": {
            "Description": "Cognito Identity Pool. Must be created after User Pool and API Gateway.",
            "Type": "AWS::Cognito::IdentityPool",
            "DependsOn": ["Cognito", "ApiGateway", "S3UploadBucket"],
            "Properties": {
                "Parameters": {
                    "AppClientId": {
                        "Fn::GetAtt": [ "Cognito", "Outputs.AppClientId" ]
                    },
                    "UserPoolProviderName": {
                        "Fn::GetAtt": [ "Cognito", "Outputs.ProviderName" ]
                    },
                    "UserPoolName": {
                        "Fn::GetAtt": [ "Cognito", "Outputs.UserPoolName" ]
                    },
                    "UploadBucketName": {
                        "Fn::GetAtt": [ "S3UploadBucket", "Outputs.UploadBucketName" ]
                    },
                    "ApiGatewayId": {
                        "Fn::GetAtt": [ "ApiGateway", "Outputs.ApiGatewayId" ]
                    }
                },
                "TemplateURL": "https://s3.amazonaws.com/my-templates-bucket/identity-pool.json"
            }
        }
    },

    "Outputs": {

    }
}

我得到这个错误:

2019-06-19 14:45:14 UTC-0400    IdentityPool    CREATE_FAILED   Property validation failure: [Encountered unsupported properties in {/}: [TemplateURL, Parameters]]

看来我的identity pool stack 的参数有些问题。但是identity pool stack 参数看起来像这样:

"Parameters" : {
        "AppClientId": {
            "Description": "ID of the App Client of the Cognito User Pool passed into this stack.",
            "Type": "String"
        },
        "UserPoolProviderName": {
            "Description": "Cognito User Pool Provider name passed into this stack.",
            "Type": "String"
        },
        "UserPoolName": {
            "Description": "Cognito User Pool Name passed into this stack.",
            "Type": "String"
        },
        "UploadBucketName": {
            "Description": "Name of the bucket that is used to upload files to.",
            "Type": "String"
        },
        "ApiGatewayId": {
            "Description": "ID of the API Gateway created for the stack.",
            "Type": "String"
        }
    },

有趣的是:我尝试自己创建每个堆栈,然后将它们的输出作为参数传递给需要这些参数的堆栈,并且每个堆栈都成功创建而没有任何问题。

我已尝试查找不受支持的内容,但找不到任何答案。

【问题讨论】:

  • “Parameters”和“TemplateURL”属性在“AWS::CloudFormation::Stack”资源类型上有效,但您的身份池资源是实际的“AWS::Cognito::IdentityPool”类型,而不是堆栈,因此这些属性在该资源类型上无效。
  • @404 再一次,你是对的!
  • 如果您想在此处发布您的答案,请告诉我,以便我关闭此问题。谢谢。
  • 没问题。作为答案发布。

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


【解决方案1】:

错误:

[Encountered unsupported properties in {/}: [TemplateURL, Parameters]]

表示这两个属性不受支持。与模板中声明的所有其余资源也使用这两个属性不同,此资源是AWS::Cognito::IdentityPool,而其余的都是AWS::CloudFormation::Stack 类型。

这两个属性只对AWS::CloudFormation::Stack 类型有效,因此会出现验证错误。

【讨论】: