我正在尝试运行 Cloudformation 模板来创建私有 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}:*/*/*/*"
}
]
}
Error -
[/Resources/PrivateGateway/Properties] 'null' values are not allowed in templates
据我所知,这似乎是 yaml 解析错误,而不是 CloudFormation 错误。
因为这是一个 yaml 模板,所以它受yaml规范 https://yaml.org/spec/1.2/spec.html#Basic.
每个节点的缩进必须比其父节点更远。所有兄弟节点必须使用完全相同的缩进级别。然而,每个兄弟节点的内容可以进一步独立缩进。
在您的示例中,下的节点Properties
没有进一步缩进,因此它们不被视为该节点的子节点,而是兄弟节点。这很可能就是您收到“空”值消息的原因,因为Properties
节点被视为“空”或“空”。
尝试在“属性:”行下每行的开头添加两个空格。这将使节点如Name
, EndpointConfiguration
, and Policy
作为子节点Properties
node.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)