CloudFormation:对 SecretManager 值的动态引用不适用于资源标签 属性

CloudFormation: Dynamic reference to SecretManager value not working for Resource's Tag Property

我想在 AWS 机密管理器中存储机密并在 CloudFormation 模板中检索它。 为了测试它,我只是把它放在一个标签的值中 -

  MainRouteTable:
    Properties:
      Tags:
        - Key: Environment
          Value: LIVE
        - Key: Name
          Value: '{{resolve:secretsmanager:tvs:SecretString:testname}}'
      VpcId: !Ref 'VPC'
    Type: AWS::EC2::RouteTable

在我 运行 使用模板的 CloudFormation 和环境启动后,标签“Name”的值为“{{resolve:secretsmanager:tvs:SecretString:testname}}”,而不是存储在 testname 中的实际秘密。

我环顾四周,无法找出问题所在。根据 AWS 文档,我做得很好。

我可以从 CLI 中取回密码 -

aws secretsmanager --region us-east-1 get-secret-value --secret-id arn:aws:secretsmanager:us-east-1:xxxxxx:secret:tvs-ZVTiDO --query SecretString --output text | jq -r .testname

有什么建议吗?

我按照此处的说明操作 - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager

SecretString 只能在少数资源和选定属性中使用。 不支持标签supported list 是:

AWS::DirectoryService::MicrosoftAD Password

AWS::DirectoryService::SimpleAD Password

AWS::ElastiCache::ReplicationGroup AuthToken

AWS::IAM::User LoginProfile Password

AWS::KinesisFirehose::DeliveryStream 

RedshiftDestinationConfiguration Password

AWS::OpsWorks::App Source Password

AWS::OpsWorks::Stack CustomCookbooksSource Password

AWS::OpsWorks::Stack RdsDbInstances DbPassword

AWS::RDS::DBCluster MasterUserPassword 

AWS::RDS::DBInstance MasterUserPassword

AWS::Redshift::Cluster MasterUserPassword

作为一般规则,机密永远不会显示在 AWS 控制台中,例如您不能使用 im CloudFormation 导出、标签等。