大网数据广告活动
服务器运维问答

CloudFormation VPC GetAtt Parameter Internal Failure

· 52CE 我爱测

I have two Cloudformation files being used to make two different stacks containing a VPC each. One is an admin VPC that will be used to access the other VPC via ssh and all that, typical bastiony use case. I spin up the admin VPC…

问题原文

原帖链接 · Ernest Mueller · CC BY-SA 3.0

I have two Cloudformation files being used to make two different stacks containing a VPC each. One is an admin VPC that will be used to access the other VPC via ssh and all that, typical bastiony use case.

I spin up the admin VPC and then pass its ID into the second CF file as a parameter specifically with the VPC Id type:

"AdminVPC": {
  "Description": "ID of the admin VPC",
  "Type": "AWS::EC2::VPC::Id"
}

But then when I am trying to set up the network ACL of the VPC, I am doing

"Type": "AWS::EC2::NetworkAclEntry",
  "Properties": {
    "CidrBlock": {
      "Fn::GetAtt": [
        {
          "Ref": "AdminVPC"
        },
        "CidrBlock"
      ]
    },

Which, when I run a ecs cf validate, yields only the message

An error occurred (ValidationError) when calling the ValidateTemplate operation: Internal Failure

It works fine if I just hardcode in a CIDR block like

"CidrBlock": "0.0.0.0/0",

But the docs claim that:

  1. Using a GetAtt to get the CIDR block off the vpc ID should work
  2. For the Fn::GetAtt attribute name, you can use the Ref function.

So I'm not sure what is wrong with this usage...

已采纳解答

原帖链接 · georgealton · CC BY-SA 3.0

the first argument to Fn::GetAtt must be the name of logical resource defined in your template, so the string must be one of the Resources created within the template.

When using AWS Parameter types all that gets passed to the template is the id of that resource, therefore the only value contained in {"Ref": "AdminVPC"} would be some like vpc-abc123 . You don't pass the VPC to the template, just its id.

The solution to your problem would be to accept the CIDR as a parameter into the template, the template creating the VPC should have an Output that Uses {"Fn::GetAtt": ["AdminVPC", "CidrBlock"]}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。