【问题标题】:How to create name tags using !Join and !FindInMap in AWS Cloudformation如何在 AWS Cloudformation 中使用 !Join 和 !FindInMap 创建名称标签
【发布时间】:2021-03-11 02:06:24
【问题描述】:

我正在尝试在 AWS 云形成模板中使用 join 和 findinmap 创建标签,但它似乎不起作用。

Mappings:
    AccountToStage:
        "123456789012":
            StageName: Beta
    Beta:
      us-east-1:
        KeyName: "Batman"
     Tags:
      -
        Key: "Name"
        Value: !Join
                  - '-'
                  - - !FindInMap
                      - !FindInMap
                          - AccountToStage
                          - !Ref "AWS::AccountId"
                          - StageName
                      - !Ref "AWS::Region"
                      - KeyName
                    - 'DBVolume'

预期输出:“Batman-DBVolume”

任何指针都非常感谢?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    在 ssm 参数上测试标签。关键是使用Json和Yaml的组合。

    AWSTemplateFormatVersion: "2010-09-09"
    Description: "Test"
    Mappings:
      AccountToStage:
        "123456789012":
          StageName: Beta
      Beta:
        us-east-1:
          KeyName: "Batman"
    Resources:
      SmsLambdaParameter:
        Type: "AWS::SSM::Parameter"
        Properties:
          Name: "/Dev/Lambda-Param"
          Type: "String"
          Value: "Test"
          Tags:
            {
              "Name":
                {
                  "Fn::Join":
                    [
                      "-",
                      [
                        !FindInMap [
                          !FindInMap [
                            AccountToStage,
                            !Ref AWS::AccountId,
                            "StageName",
                          ],
                          !Ref AWS::Region,
                          "KeyName",
                        ],
                        "DBVolume",
                      ],
                    ],
                },
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      相关资源
      最近更新 更多