模板中不允许使用AWS Cloudformation [/ Resources / PrivateGateway / Properties]'null'值 [英] AWS Cloudformation [/Resources/PrivateGateway/Properties] 'null' values are not allowed in templates

查看:85
本文介绍了模板中不允许使用AWS Cloudformation [/ Resources / PrivateGateway / Properties]'null'值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行Cloudformation模板来创建私有API网关,但出现空值错误,无法弄清原因,

以下是我正在使用的模板尝试使用-

I am trying to run a Cloudformation template to create a private API Gateway, I am getting a null value error, not able to figure out why,
Following is the template I'm trying to work with -

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错误。

From what I can tell, this appears to be a yaml parsing error, rather than a CloudFormation error.

由于这是一个Yaml模板,因此必须遵守 yaml规范

Because this is a yaml template, it is subject to the 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下的节点不再缩进,因此它们不被视为该节点的子代,而是同级。这很可能是为什么您收到空值消息的原因,因为 Properties 节点被视为空或空。

In your example, the nodes under Properties are not indented further, so they are not considered children of that node, but siblings. This is very likely why you are getting a 'null' values message, as the Properties node is considered 'empty' or 'null'.

尝试在属性:行下的每一行开头添加两个空格。这将使诸如 Name EndpointConfiguration Policy 作为 Properties 节点的子节点。

Try adding two spaces at the beginning of every line under the 'Properties:' line. This will make the nodes such as Name, EndpointConfiguration, and Policy as child nodes to the Properties node.

这篇关于模板中不允许使用AWS Cloudformation [/ Resources / PrivateGateway / Properties]'null'值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆