amazon-web-services - 您可以将 "Fn::FindInMap"嵌套在 "Fn::Sub"中吗?

标签 amazon-web-services aws-cloudformation

我正在这样做:

{"Fn::Join": [":", [
    "arn:aws:sns",
    { "Ref": "AWS::Region"},
    { "Ref": "AWS::AccountId"},
    {"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }
]]

但我更喜欢像这样使用 SUB 但它不是有效的 JSON:

{"Fn::Sub" : "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${"Fn::FindInMap" : [ "config", "mytopic", { "Ref" : "deployment" } ] }"}

最佳答案

您无法直接从 Fn::Sub 模板调用 Fn::FindInMapOnly a limited number of expressions work OOTB.

相反,您可以将其他变量传递给 Fn::Sub。例如:

      DefinitionString: !Sub 
        - |-
          {
             "Comment":"Extract metadata and anonymize the videoclip",
             "StartAt":"ExtractMetadataAndAnonymize",
             "States":{
                "ExtractMetadataAndAnonymize":{
                   "Type":"Parallel",
                   "Next":"LogResult",
                   "Branches":[
                      {
                         "StartAt":"AlarmIfVideoverarbeitungClusterIsEmpty",
                         "States":{
                            "AlarmIfVideoverarbeitungClusterIsEmpty":{
                               "Type":"Task",
                               "Resource":"${EmptyVideoverarbeitungClusterAlarmFunction_Arn}",
                               ....
                }
             }
          }
        - EmptyVideoverarbeitungClusterAlarmFunction_Arn: !ImportValue 
            'Fn::Sub': 'stk-${EnvType}-${EnvId}-videoverarbeitung-cluster-EmptyVideoverarbeitungClusterAlarmFunction-Arn'

在这里,我计算一些值并将其作为 EmptyVideoverarbeitungClusterAlarmFunction_Arn 变量传递给 Sub

关于amazon-web-services - 您可以将 "Fn::FindInMap"嵌套在 "Fn::Sub"中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58986248/

相关文章:

apache - 负载平衡 Web 服务器 + 保持内容同步

amazon-web-services - Cloudwatch boto3 put_log_events 返回错误

amazon-web-services - 用于从 Auto Scaling 组中获取实例并依次获取该实例的主机名的脚本

amazon-web-services - 如何通过云形成模板从自定义 ami 运行 ec2 实例

amazon-web-services - AWS Cloudformation 在创建之前删除资源

amazon-web-services - 下拉列表中填充了可用的 AWS KMS key 作为 aws CFT 中的参数

amazon-web-services - AWS CodeDeploy 未在 Lightsail 基本设置 SSL 上部署

amazon-web-services - 是否不需要将负载均衡器与 ElasticSearch 一起使用?

amazon-web-services - 我可以使用现有的 AWS IAM 角色通过 Cloudformation 模板创建 S3 存储桶吗?

amazon-web-services - 是否可以将参数文件传递到 AWS::CloudFormation::Stack