为什么GetAttr在cloudformation模板参数上不起作用? [英] Why does GetAttr not work on cloudformation template parameters?

查看:76
本文介绍了为什么GetAttr在cloudformation模板参数上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在父子关系中具有cloudformation模板的集合,并希望将AWS :: IAM :: Role传递到子堆栈的参数中,并使用GetAttr获取Arn。

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.

这将使验证失败,因为只能对资源而不是参数调用GetAttr。

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

任何人都知道/猜测为什么以此方式设计?

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

这不是问题,因为可以通过将Arn传递到堆栈中来解决,我很好奇

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

推荐答案

什么 Fn :: GetAttr Parameters 正在尝试在 AWS CloudFormation 中执行的操作根本不同。根据AWS文档:

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


固有函数Fn :: GetAtt从模板中的资源返回属性
的值。

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


创建堆栈时,可以使用可选的Parameters部分将值传递到
模板中。使用参数,您可以创建每次创建堆栈时都自定义的
模板。

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

我相信您的困惑源于您试图从以下方面考虑这一事实:面向对象/其他编程范例,其中资源参数是某种对象,而 Fn :: GetAttr 是一个泛型函数,用于检索作为参数传入的引用的值。

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.

这篇关于为什么GetAttr在cloudformation模板参数上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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