anyone know why creation of a CloudFront public ke...
# help
s
anyone know why creation of a CloudFront public key would fail like this?
Copy code
Resource handler returned message: "Invalid request provided: AWS::CloudFront::PublicKey" (RequestToken: 1457a7a8-cd44-1785-514a-317b7c2dd2d9, HandlerErrorCode: InvalidRequest)
as usual, not much error detail from AWS 😕
Copy code
const publicKeyContents = fs.readFileSync('./public_key.pem');
  const publicKey = new cloudfront.PublicKey(stack, 'PublicKey', {
    encodedKey: publicKeyContents.toString(),
    publicKeyName: 'Signature verifier',
  });
a
could you remove any newlines from your .pem file and try again?
s
I was under the impression the newlines are needed. but sure, I can try. I have nothing to lose 😄
a
haha, fingers crossed! 😂
s
I’m also waiting for an AWS support rep via chat. they’re quite slow these days
nah, stripping newlines didn’t help 😞
so frustrating
AWS’s error messages are terrible
Copy code
"PublicKeyCCC1C639": {
      "Type": "AWS::CloudFront::PublicKey",
      "Properties": {
        "PublicKeyConfig": {
          "CallerReference": "c87e7dc48517c9a46c821bd49aa5f453656375a8c3",
          "EncodedKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6UXP2xFSwwD1d6hGEGUI\nIR7xDbNetjMmp+iG8QRpMYGKk8ExeRZQFb0eZvs8cTSF0WKaBzmhJr60zazUKHZg\nuIeD/2eaHFCFHJRZAd6uDwhCjP4OKgGUiqpfhbUhpVby+hdwvfKfWjDtktXOhgeB\noOXpyTVkEpgJanthsCKrMOhQo4YD1w2QydhBqREWnlnl8kooh2v/w3lgs4ldmIv3\n+UeeLLutNboZ+x/q3ewtBFN1W+Xpe48udTxkGY8DLYhqfhBQ+kU39SBfxaRSeC1T\nljd3gQ9S6MSpC1KheZXzlOJU7ojdOGTlnJxHzKUXmEW7h81ojVnfLCmwpYAwNPlt\njQIDAQAB\n-----END PUBLIC KEY-----\n",
          "Name": "Signature verifier"
        }
      },
      "Metadata": {
        "aws:cdk:path": "dev-microservices-core/PublicKey/Resource"
      }
    },
a
could you try a regex search for
\n
and remove it, I have a hunch that this is the issue, I’ve come across something similar before.
s
I did that, yeah.
.replace(/\n/g, '')
or.. oh I see. you mean an actual string `/n’
a
The actual string.
s
I can easily check if it’s a newline or “\n”. one sec.
a
sure.
s
nope, it’s a real newline
a
remove those
\n
as well.
s
I did that before. stripping newlines didn’t fix it
a
I think they will be parsed to new lines. Oh! I see.
s
yeah. and in the actual CloudFormation JSON, it’s a string “\n”, but that’s valid. in JSON, “\n” will get parsed as a newline
thanks for trying to help 🙂 hopefully AWS tech support will have an answer
a
Another hunch, replace all
\n
with actual newlines. I am just trying my luck here.
s
uh oh. I think the key name was invalid. one sec
a
oh lol! 😂
s
oh geez.
publicKeyName
can’t have spaces in it. yep, that fixed it. geez! how hard is it to show me an error, “invalid key name”
a
haha damn!