AWS CLI Could not connect to the endpoint URL: "https://iam.af-south-1.amazonaws.com/"

Viewed 24

I am a beginner at using the AWS CLI.

I have run aws configure and setup my IAM user credentials.

Default region name: [Africa (Cape Town)]: af-south-1

When I try to run any command to interact with AWS resources, I get the below response:

Could not connect to the endpoint URL: "https://iam.af-south-1.amazonaws.com/"

How can I troubleshoot this, from the network perspective I can reach most domains and different other subdomains off the amazonaws domain.

1 Answers

The iam.af-south-1.amazonaws.com DNS name does not resolve to an IP address because AWS IAM is a global service. It only operates out of the us-east-1 region, accessed via iam.amazonaws.com.

You can test this by doing a few tests:

  • curl https://dynamodb.us-west-2.amazonaws.com -- works
  • curl https://iam.us-west-2.amazonaws.com -- does not work
  • curl https://iam.amazonaws.com -- works

As to WHY your system is attempting to access iam.af-south-1.amazonaws.com, I'm not sure. It shouldn't be doing that, even if you set the default region to af-south-1.

Related