为什么 GetAttr 不适用于 cloudformation 模板参数?
Why does GetAttr not work on cloudformation template parameters?
在父子关系中有一组 cloudformation 模板,想将一个 AWS::IAM::Role 传递到子堆栈的参数中,并使用 GetAttr 获取 Arn。
验证失败,因为只能对资源调用 GetAttr,不能对参数调用。
有人know/guess为什么这样设计?
这不是问题,因为它可以通过将 Arn 传递到堆栈中来解决,我真的很好奇
Fn::GetAttr
和 Parameters
在 AWS CloudFormation 中尝试做的事情根本不同。根据 AWS 文档:
The intrinsic function Fn::GetAtt returns the value of an attribute
from a resource in the template.
You can use the optional Parameters section to pass values into your
template when you create a stack. With parameters, you can create
templates that are customized each time you create a stack.
[2]http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
我相信您的困惑源于您试图从 object-oriented/some 其他编程范式的角度来思考这个问题,其中 Resources
和 Parameters
是一些对象的种类,Fn::GetAttr
是一个通用函数,它检索作为参数传入的引用的值。
就我而言,我想访问嵌套堆栈中的 ARN 和名称等资源属性。如果我传递资源字符串并使用 GetAtt 获取这些,我不需要将它们作为两个参数传递。由于这个限制,我不得不将它们作为两个参数传递。
在父子关系中有一组 cloudformation 模板,想将一个 AWS::IAM::Role 传递到子堆栈的参数中,并使用 GetAttr 获取 Arn。
验证失败,因为只能对资源调用 GetAttr,不能对参数调用。
有人know/guess为什么这样设计?
这不是问题,因为它可以通过将 Arn 传递到堆栈中来解决,我真的很好奇
Fn::GetAttr
和 Parameters
在 AWS CloudFormation 中尝试做的事情根本不同。根据 AWS 文档:
The intrinsic function Fn::GetAtt returns the value of an attribute from a resource in the template.
You can use the optional Parameters section to pass values into your template when you create a stack. With parameters, you can create templates that are customized each time you create a stack.
[2]http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
我相信您的困惑源于您试图从 object-oriented/some 其他编程范式的角度来思考这个问题,其中 Resources
和 Parameters
是一些对象的种类,Fn::GetAttr
是一个通用函数,它检索作为参数传入的引用的值。
就我而言,我想访问嵌套堆栈中的 ARN 和名称等资源属性。如果我传递资源字符串并使用 GetAtt 获取这些,我不需要将它们作为两个参数传递。由于这个限制,我不得不将它们作为两个参数传递。