将 Secrets Manager 参数引用到秘密字符串

Reference Secrets Manager Parameters to Secret String

是否有任何方法可以通过 CloudFormation 引用 Secrets Manager 中 SecretString 字段中的参数?

按照我制作脚本的方式,!Ref 参数是文本而不是对参数的引用。

AWSTemplateFormatVersion: 2010-09-09

Parameters:

  Name:
    Type: String
  myuserparameter:
    Type: String
  mypasswordparameter:
    Type: String

Resources:  
  
  SecretsManager:
    Type: AWS::SecretsManager::Secret
    Properties:
      Name: !Ref Name
      SecretString: '{"username":"!Ref myuserparameter,"password":"Ref mypasswordparameter"}'

这会起作用:

AWSTemplateFormatVersion: 2010-09-09

Parameters:

  Name:
    Type: String
  myuserparameter:
    Type: String
  mypasswordparameter:
    Type: String

Resources:  
  
  SecretsManager:
    Type: AWS::SecretsManager::Secret
    Properties:
      Name: !Ref Name
      SecretString: !Sub '{"username": "${myuserparameter}","password": "${mypasswordparameter}"}'