Bug Fix: Invalid endpoint

Troubleshooting for ValueError: Invalid endpoint

1. Problem

  • After updating the environment variables for the backend-flask container in the docker-compose file, I would keep running into this issue:

    • Invalid endpoint: https://logs..amazonaws.com

  • The most logical guess would be something is wrong with the AWS region configuration. The CloudWatch logs are sent over to AWS through thie CW service endpoint, which has the following structure:

    • logs.<YOUR_AWS_REGION>.amazonaws.com

  • I use us-east-1 (N. Virginia) so it should be:

    • logs.us-east-1.amazonaws.com

2. Analysis & Solution

I tried echoing all the variables I added to the env variables for the backend in docker-compose. It turns out, AWS_DEFAULT_REGION has no value set to it.

You can assign values to environmental variables in Linux as follows:

export AWS_DEFAULT_REGION="us-east-1"
gp env AWS_DEFAULT_REGION="us-east-1" # gitpod only

I restarted the docker-compose, however, this wouldn't fix the issue. In case you are using Gitpod, it is highly recommended that you create a brand new workspace, as this issue with updated env variables often happens with Gitpod workspaces.


3. Result

After ticking all the boxes of the list suggested in the step 2. Analysis, the CloudWatch agent correctly created a log group called cruddur.

The CloudWatch agent is diligently working on our Cruddur backend and sending over http requests to AWS CloudWatch.

A list of log streams coming through
Even logs showing a successful HTTP GET request handling

Resources

Last updated