amazon-web-services - 如果 AWS CloudFormation 模板生成器创建的模板无效,为什么还要使用它?

标签 amazon-web-services aws-cloudformation

我正在尝试自动化我的服务器设置过程,因此我最终考虑使用 CloudFormation。我启动了 CloudFormation 模板服务,以便它可以内省(introspection)我当前的设置(在账户 A 中)并生成一个模板供我在新账户(账户 B)中使用。我正在俄勒冈州构建模板并尝试在俄勒冈州运行它。完整模板在这里(真实IP、账号和密码已被删除):https://gist.github.com/cannikin/9801aa3451d538be1689

当我尝试基于该模板启动堆栈时,我收到 15 个 CREATE_FAILED 事件,然后整个事件回滚。查看一些消息,我看到很多 AWS::EC2::SecurityGroupEgress | egress3 | Encountered unsupported property CidrIP 如果我在模板中查找 egress3:

"egress3": {
  "Type": "AWS::EC2::SecurityGroupEgress",
  "Properties": {
    "GroupId": {
      "Ref": "sgweb"
    },
    "IpProtocol": "-1",
    "CidrIP": "0.0.0.0/0"
  }
}

这似乎是一个非常简单的规则:允许到任何 IP 的出站连接。我什至没有创建该规则,它只是新安全组的默认出站规则(入站规则是您想要限制某些 IP 地址的规则)。

这怎么是无效的,特别是当它是由他们自己的模板生成器创建时?我不应该包含导出规则吗?

我在其中多次看到我的帐户 A 帐号(123456789),也许需要将其交换到帐户 B 帐号?

最佳答案

它无效,因为您有语法错误。 "CidrIP" 应为 "CidrIp" 。例如https://gist.github.com/cannikin/9801aa3451d538be1689#file-cloudformation-template-L460

我建议您首先使用 aws cli 运行“测试”。例如:

aws cloudformation validate-template --template-body file://foo.json

关于amazon-web-services - 如果 AWS CloudFormation 模板生成器创建的模板无效,为什么还要使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29154689/

相关文章:

python - 在 Redshift 中创建 python UDF 时出错

laravel - 上传到 S3 之前的 AWS 临时文件?

node.js - 错误 [CredentialsError] : Missing credentials in config, 如果使用 AWS_CONFIG_FILE,设置 AWS_SDK_LOAD_CONFIG=1

amazon-web-services - 用于将新 EBS 卷附加到 Windows 和分区的 AWS CloudFormation 模板

amazon-web-services - AWS kibana/ES尝试创建策略但获取 “authorization exception”

json - 如何向 json IAM 策略添加注释?

amazon-web-services - aws cloudformation - 'content.s3Bucket' 处的值无法满足约束 : Member must satisfy regular expression pattern

amazon-web-services - 如何使用 CloudFormation 将 IAM 角色与 Aurora 集群关联?

amazon-web-services - 如何使用 CloudFormation 允许使用用户名和电子邮件登录的 AWS Cognito 配置?

amazon-web-services - 如何从 CloudFormation 模板中引用 json 配置值?