amazon-web-services - 如何在 AWS 网络防火墙的 cloudformation 中读取 !GetAtt 返回的键列表:值
问题描述
我正在尝试访问在不同 AZ 的 3 个子网中创建的 3 个网络防火墙端点,这些端点被添加到路由表中:
网络防火墙的逻辑名称是“NetworkFirewall”
!GetAtt NetworkFirewall.EndpointIds.${AWS::Region}b
!GetAtt NetworkFirewall.EndpointIds.${AWS::Region}c```
As specified in AWS docs:
Fn::GetAtt
The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.
EndpointIds
The unique IDs of the firewall endpoints for all of the subnets that you attached to the firewall. The subnets are not listed in any particular order. For example: **["us-west-2c:vpce-111122223333", "us-west-2a:vpce-987654321098", "us-west-2b:vpce-012345678901"]**.
But this way:
!GetAtt NetworkFirewall.EndpointIds.${AWS::Region}a
of accessing endpoints, seems to be not working.
Any tips will be helpfull
解决方案
正如你已经观察到的,你不能做你想做的事。CloudFormation (CFN) 根本不支持搜索列表等操作。
如果您想继续使用 CFN,实现您想要的唯一方法是通过自定义资源。在您的情况下,您必须以lambda 函数的形式开发这样的资源,它会EndpointIds
为您进行自定义搜索和过滤。
另一种方法是不使用 CFN。您可以尝试使用其他基础设施即代码工具。例如,在 terraform 中,您想要的此类操作是自然且易于实现的。
推荐阅读
- c++ - C++ 无法使用嵌套循环索引数组的元素
- sql - 尽管获得了 GRANT EXECUTE,但我在函数调用中得到“ORA-00904:无效标识符”
- javascript - 需要将客户价值传递回 React 中的 POST 操作
- c++ - gtest 单元测试目标配置文件路径
- xamarin - 无法从“Xamarin.Forms.Entry”转换为“Tweetinvi.Models.IUserIdentifier”
- java - RestTemplate JSON 反序列化
- bash - 从 jenkins 调用的 Minicom 脚本在退出 '! killall -9 minicom'
- hibernate - 强制不在杰克逊中序列化未获取的惰性对象
- isabelle - 在 Isabelle 中探索已完成的理论
- android - 使用 android:drawableLeft 和 png 时添加圆角