Merlin Joseph
Merlin Joseph

Reputation: 141

AWS CloudWatch Client Side Logging

I am running an react app. I want to log error to my aws cloudwatch without hard coding the access key and secret key on my client side code. I am using 'Error Boundary Component' for catching error.

Thank you for your help.

Upvotes: 14

Views: 4519

Answers (1)

jwh20
jwh20

Reputation: 678

I assume by "react app" you mean a React-based web application, often called an SPA for Single Page Application.

In that case you are correct, you do not want to hard-code and credentials as that would expose them to any user who has access to the page.

The most common architecture for doing this is to setup the following:

  1. A Lambda that will take your logging event and log it for you in Cloudwatch.
  2. An API-Gateway that your application can call that will trigger the Lambda.
  3. An Authorizer on the API-Gateway resource that will validate a JWT that is passed from the application.
  4. AWS Cognito that will supply your application with a JWT based on some login, either directly or via some integration with another service that is applicable for your case.

Upvotes: 13

Related Questions