gpt4 book ai didi

amazon-web-services - AWS Cloudformation [/Resources/PrivateGateway/Properties] 模板中不允许使用 'null' 值

转载 作者:行者123 更新时间:2023-12-03 07:13:37 25 4
gpt4 key购买 nike

我正在尝试运行 Cloudformation 模板来创建私有(private) API 网关,但收到空值错误,无法找出原因,
以下是我尝试使用的模板 -

AWSTemplateFormatVersion: 2010-09-09
Transform: 'AWS::Serverless-2016-10-31'
Description: Api Template Stack

Parameters:
VpcId:
Type: String
Default: "vpc-xxxxxx"

Resources:
PrivateGateway:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Name: 'private-gw'
EndpointConfiguration:
Types:
- PRIVATE
Policy: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-east-1:${AWS::AccountId}:*/*/*/*",
"Condition": {
"StringNotEquals": {
"aws:sourceVpc": !Ref VpcId
}
}
},
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-east-1:${AWS::AccountId}:*/*/*/*"
}
]
}

错误 -

[/Resources/PrivateGateway/Properties] 'null' values are not allowed in templates

最佳答案

据我所知,这似乎是 yaml 解析错误,而不是 CloudFormation 错误。

由于这是一个 yaml 模板,因此受 yaml specification 的约束.

Each node must be indented further than its parent node. All sibling nodes must use the exact same indentation level. However the content of each sibling node may be further indented independently.

在您的示例中,Properties 下的节点不会进一步缩进,因此它们不被视为该节点的子节点,而是兄弟节点。这很可能就是您收到“null”值消息的原因,因为 Properties 节点被视为“空”或“null”。

尝试在“Properties:”行下每行的开头添加两个空格。这将使 NameEndpointConfigurationPolicy 等节点成为 Properties 节点的子节点。

关于amazon-web-services - AWS Cloudformation [/Resources/PrivateGateway/Properties] 模板中不允许使用 'null' 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57790229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com