Why does GetAttr not work on cloudformation template parameters?

余生颓废 提交于 2019-12-08 07:12:29

问题


Have a collection of cloudformation templates in a parent-child relationship and want to pass an AWS::IAM::Role into the parameters of a child stack and use GetAttr to get the Arn.

This fails validation because can only call GetAttr on resources, not on parameters.

Anyone know/guess why this is designed in this way?

It's not a problem as it can be worked around by just passing the Arn into the stack, I'm just curious really


回答1:


What Fn::GetAttr and Parameters are trying to do in AWS CloudFormation is fundamentally different. As per AWS docs:

The intrinsic function Fn::GetAtt returns the value of an attribute from a resource in the template.

[1] http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html

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

I believe your confusion is stemming from the fact that you're trying to think of this in terms of the object-oriented/some other programming paradigm, where Resources and Parameters are some kind of objects and Fn::GetAttr is a generic function which retrieves the value of a reference that's passed in as an argument.



来源:https://stackoverflow.com/questions/42629914/why-does-getattr-not-work-on-cloudformation-template-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!