Serverless Cloudwatch events appearing encrypted / serialized

I’m testing out Cloudwatch logs as a trigger for serverless functions. However when my serverless function is triggered, it’s just outputting jibberish, which I figured was some form of encryption. Unfortunately I don’t know what that encryption is.

Here’s the output:

{"awslogs":{"data":"H4sIAAAAAAAAAGVRX2sjIRz8KovPa/Gn679AHtK7JATatJDAPRylmFVSqVkXNSlL6XevSbmnA59mxhln/EQnl7M5uv00OjRDvxf7xevjcrdbrJeoRfFjcKnCShIlNJdUMVrhEI/rFM9jZcxgwlR8n1/dxQ0l/7C7kpw5VXqLn7bOh5Dxo+nvY3zHzynehdibgLXinCpOMLHigAkwhR11FksCSiulwNpDtcvnQ+6TH4uPw8qH4lJGs7/IGh+m0Uw4u3RxKdQa2LoL/hXi2X6Y0r8tbw96iMe8+8/ipvpzVVUe8IotHpbdhsJ6c49ebhV+btekT+RtbcI4qE4STVgHwDqliRYSuGCEXhnCuCCaMQFXoaBUCqk6oKo2KL6OXMyp7gVcSsmEBs01tP/Gr/aUgMZAMSMN8Nn16AYTTkgzejtXDHjblLe6qp3LmtVRraGiirRNrssnX6b5Zrt6apt9zfLDsTFDc/sS9PXy9Q34BmF05wEAAA=="}}

And here’s the function’s code:

const handler = async (event) => {
  console.log('*********RECEIVED EVENT FROM CLOUDWATCH**********')
  console.log(JSON.stringify(event));
  return {
    statusCode: 200,
    body: JSON.stringify(
      event,
      null,
      2
    )
  }
};

export { handler };

It looks like the data is base64 encoded. Have you tried decoding it?

Yeah that turned out to be the issue. It wasn’t just base64 though it was also gzipped so base64 was returning some jumbled text. Oh well, now fixed!