Search code examples
amazon-web-servicesamazon-s3localstack

Custom endpoint URL to AWS using environment variable


I am trying to set custom endpoint URL with AWS CLI to point to Localstack. This command works perfectly:

AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test aws --endpoint-url=http://localhost:4566 s3 ls

However, for some reason, I don't want to use --endpoint-url option. I need to use environment variables. I read in the documentation about AWS_ENDPOINT_URL variable and I tried this:

AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_ENDPOINT_URL=http://localhost:4566 aws s3 ls

But I get this error:

An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.

It seems it's not going to Localstack, at least the AWS STS. I tried also setting the variables AWS_ENDPOINT_URL_STS and AWS_ENDPOINT_URL_S3 to http://localhost:4566, but I get the same error.


Solution

  • According to the changelog:

    2.13.0

    feature:configuration: Configure the endpoint URL in the shared configuration file or via an environment variable for a specific AWS service or all AWS services.

    The endpoint URL configuration via environment variable was added in version 2.13.0, released around Jul 7, 2023.

    Updating the AWS CLI to update to the latest version should fix this issue.