【问题标题】:CloudFormation Transform inside FindInMapFindInMap 中的 CloudFormation 转换
【发布时间】:2021-01-02 10:38:36
【问题描述】:

我正在尝试转换传递给 FindInMap 的键之一。我试图遵循的例子来自这里:

https://github.com/awslabs/aws-cloudformation-templates/tree/master/aws/services/CloudFormation/MacrosExamples/StringFunctions/#basic-usage

        - Fn::FindInMap
          - 'Fn::Transform':
               Name: 'String'
               Parameters:
                  InputString: !Ref Env
                  Operation:
                    Replace:
                      Old: "-"
                      New: ""
          - !Ref "AWS::Region"
          - 'AppSubnetIds'

我收到以下错误消息作为响应:

mapping values are not allowed here
  in "<unicode string>", line 186, column 28:
              - 'Fn::Transform':
                               ^ (line: 186)

我的语法有问题吗?还是一般不可能?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    这是一个语法错误。 in the repository 给出了 Replace 操作的一个示例。这是我能够部署的模板,它在FindInMap 中使用Transform,并创建一个带有test-key:test-value 标签的S3 存储桶:

    Parameters:
      Env:
        Type: String
        Default: env-dev
    
    Mappings:
      envdev:
        us-east-1:
          AppSubnetIds: test-value
    
    Resources:
      S3Bucket:
        Type: "AWS::S3::Bucket"
        Properties:
          Tags:
            - Key: test-key
              Value: 
                'Fn::FindInMap':
                  - 'Fn::Transform':
                       Name: 'String'
                       Parameters:
                          InputString: !Ref Env
                          Operation: Replace
                          Old: "-"
                          New: ""
                  - !Ref "AWS::Region"
                  - AppSubnetIds
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多