title: How to normalize a private key stored on AWS secrets manager
body: <p>EDIT: <strong>AS OF Feb 2020, AWS SEEMS TO have FIXED THIS BUG. THE BASE64ing and other wise is no longer needed.</strong></p>
  
  <hr>
  
  <p>I have my secret stored as a string but of course when aws stores the secret it removes white space and line breaks. On top of it it wraps the value in json.</p>
  
  <p>When I run <code>aws secretsmanager get-secret-value --secret-id my-private-key &gt; private.pem</code> it returns something like.</p>
  
  <pre><code>{
      "Name": "ai-data-devops-ansible-deploy-key",
      "VersionId": "fedafe24-d3eb-4964-9a8f-7f4ecb375a35",
      "SecretString": "-----BEGIN RSA PRIVATE KEY-----\nasdkmnasefkljzsdkffjsldkgfjlzkmsdflkNOTAREALKEYasddkjnsfdlzxdfvlkmdggo=\n-----END RSA PRIVATE KEY-----\n",
      "VersionStages": [
          "AWSCURRENT"
      ],
      "CreatedDate": 1568147513.11,
      "ARN": "arn:aws:secretsmanager:us-east-1:13726472r4:secret:my-private-key-XQuwafs"
  }
  </code></pre>
  
  <p>So I need to:</p>
  
  <ul>
  <li>Strip get the value out of json</li>
  <li>Reformat the string to be more like</li>
  </ul>
  
  <pre><code>-----BEGIN RSA PRIVATE KEY-----
  asdkmnasefkljzsdkffjsldkgfjlzkmsdflkNOTAREALKEYasddkjnsfdlzxdfvlkmdggo=
  -----END RSA PRIVATE KEY-----
  </code></pre>