title: How to get private key from secret manager?
body: <p>I need to store a Private Key in AWS. Because when I create an ec2 instance from AWS I need to use this primary key to auth in provisioner &quot;remote-exec&quot;. I don't want to save in repo AWS.</p>
  <p>It's a good idea to save a private key in Secret Manager? And then consume it?</p>
  <p>And in the case affirmative, How to save the primary key in Secret Manager and then retrieve in TF aws_secretsmanager_secret_version?</p>
  <p>In my case, if I validate from a file(), it's working but if I validate from a string, is failed.</p>
  <pre><code>connection {
      host = self.private_ip
      type = &quot;ssh&quot;
      user = &quot;ec2-user&quot;
      #private_key = file(&quot;${path.module}/key&quot;)   &lt;-- Is working
      private_key = jsondecode(data.aws_secretsmanager_secret_version.secret_terraform.secret_string)[&quot;ec2_key&quot;]    &lt;-- not working. Error: Failed to read ssh private key: no key found
  }
  </code></pre>