title: Dynamic References to Specify Secret Manager Values in AWS Cloudformation
body: <p>Is there anyway we can pass <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html" rel="noreferrer">dynamic references</a> to <a href="https://docs.amazonaws.cn/en_us/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager" rel="noreferrer">Secret Manager</a> to AWS Launch Config User Data?</p>
  
  <p>Here is the code snippet I tried: </p>
  
  <pre><code>"SampleLaunchConfig": {
              "Type": "AWS::AutoScaling::LaunchConfiguration",
               "Properties": {
                  "ImageId": {
                      "Fn::FindInMap": [
                          "AWSRegionArch2AMI",
                          {
                              "Ref": "AWS::Region"
                          },
                          "AMI"
                      ]
                  },
                  "UserData": {
                      "Fn::Base64": {
                          "Fn::Join": [
                              "",
                              [
                                  "#!/bin/bash -xe\n",
                                  "yum update -y\n",
                                  "useradd -p &lt;&lt;pwd&gt;&gt;{{resolve:secretsmanager:Credentials:SecretString:userName}}\n",
                                  "\n"
                              ]
                          ]
                      }
                  }
          }
      }
  </code></pre>
  
  <p>Seems error in getting the useradd: invalid user name '{{resolve:secretsmanager:Credentials:SecretString:userName}}'</p>
  
  <p>How can I pass Secret Manager secret value to cloudformation user data ? </p>