0

Is there a method to pass a SSH Key through to a Cloudformation script for custom recipes repo when configuring an Amazon Web Services OpsWorks stack besides mangling the newline characters and placing value directly in the JSON script? I've been going around in circles with this so just in case I appear to be blathering:

  1. CloudFormation script
  2. Creates OpsWorks Stack
  3. Stack has a custom Chef cookbook configured as a Git(Hub) repo
  4. Repo needs a SSH key

The only way I have found to get this to work so far is to convert the new lines of the SSH key to \r\n and put the key directly into the CloudFormation JSON script. Not ideal!!

-Cloudformation Snippet-

            ...
            "UseOpsworksSecurityGroups": "false",
            "CustomCookbooksSource": {
                "Revision": {
                    "Ref": "GitRepoRevision"
                },
                "SshKey": "-----BEGIN RSA PRIVATE KEY-----\r\nasdf123asdf123asdf123...\r\n-----END RSA PRIVATE KEY-----",
                "Type": "git",
                "Url": {
                    "Ref": "GitRepoURL"
                }
            }
            ...
J. Lawson
  • 86
  • 10
  • You didn't ask a question, however, I think the answer you are looking for is to use a parameter for the SSH key. Here is a template with an example: https://github.com/pythian/opsviz/blob/master/cloudformation.json – jordanm Oct 22 '15 at 04:11
  • Edited to a proper question and clarified, but you did get the correct intent. The method in the template is one I've already tried and it doesn't appear to work as is or I'm horribly misusing it. I get "Custom Cookbooks Source's Ssh Key: is invalid" with any format I use for the SSH Key. Format being new line characters or \r\n. – J. Lawson Oct 22 '15 at 17:11

0 Answers0