首页 > 解决方案 > 如何在cloudformation中为资源自定义名称添加随机后缀值?

问题描述

我正在使用带有随机后缀的自定义名称创建 cloudformation 资源

CF 堆栈模板 附加模板:

MyMacro:
    Type: AWS::CloudFormation::Macro
    Properties:
      Name: 'random-string'
      Description: 'random string generator'
      FunctionName: 'arn:aws:lambda:eu-west-1:xxxxxx:function:random-string'
  CreateSGLambdaExecutionRole:
    Type: AWS::IAM::Role
    DependsOn: MyMacro
    Properties:
      RoleName: 
        *Fn::Transform:
          - Name: MyMacro
            Parameters:
              InputString: ud-sg-MyMacro*

我需要一个像“ud-sg-ABCD123”这样的角色名称。

创建此 CF 堆栈时出现以下错误:

未找到名为 ::MyMacro 的转换。用户请求回滚。

标签: amazon-web-servicesamazon-cloudformation

解决方案


推荐阅读