title: EndpointConnectionError: Could not connect to the endpoint URL: "http://169.254.169.254/....."
body: <p>I am trying to create AWS RDS and deploy lambda function using a python script. However, I am getting below error, looks like it is unable to communicate with the aws commands to create rds.</p>
  
  <pre><code>DEBUG: Caught retryable HTTP exception while making metadata service request to http://169.254.169.254/latest/meta-data/iam/security-credentials/: Could not connect to the endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
  
  Traceback (most recent call last):
  
   File "/usr/lib/python2.7/site-packages/botocore/utils.py", line 303, in _get_request
   response = self._session.send(request.prepare())
  File "/usr/lib/python2.7/site-packages/botocore/httpsession.py", line 282, in send raise EndpointConnectionError(endpoint_url=request.url, error=e)
  
  EndpointConnectionError: Could not connect to the endpoint URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
  </code></pre>
  
  <p>I am getting the aws credentials through SSO okta. In the ~/.aws directory,below are the contents of 'credentials' and 'config' file respectively. </p>
  
  <pre><code>[default]
  aws_access_key_id = &lt;Key Id&gt;
  aws_secret_access_key = &lt;Secret Key&gt;
  aws_session_token = &lt;Token&gt;
  
  [default]
  region = us-west-2
  
  ```python
  ```
  for az in availability_zones:
      if aurora.get_db_instance(db_instance_identifier + "-" + az)[0] != 0:
          aurora.create_db_instance(db_cluster_identifier, db_instance_identifier + "-" + az, az, subnet_group_identifier, db_instance_type)
      else:
          aurora.modify_db_instance(db_cluster_identifier, db_instance_identifier + "-" + az, az, db_instance_type)
  
  # Wait for DB to become available for connection
  iter_max = 15
  iteration = 0
  for az in availability_zones:
      while aurora.get_db_instance(db_instance_identifier + "-" + az)[1]["DBInstances"][0]["DBInstanceStatus"] != "available":
          iteration += 1
          if iteration &lt; iter_max:
              logging.info("Waiting for DB instances to become available - iteration " + str(iteration) + " of " + str(iter_max))
              time.sleep(10*iteration)
          else:
              raise Exception("Waiting for DB Instance to become available timed out!")
  
  cluster_endpoint = aurora.get_db_cluster(db_cluster_identifier)[1]["DBClusters"][0]["Endpoint"]
  </code></pre>
  
  <p>The actual error below, coming from the while loop, DEBUG shows unable to locate credential, but the credential is there. I can deploy an Elastic Beanstalk environment from cli using the same aws credential, but not this. Looks like the above aurora.create_db_instance command failed. </p>
  
  <pre><code>DEBUG: Unable to locate credentials
  
  Traceback (most recent call last):
  
    File "./deploy_api.py", line 753, in &lt;module&gt; sync_rds()
    File "./deploy_api.py", line 57, in sync_rds
      while aurora.get_db_instance(db_instance_identifier + "-" + az)[1]["DBInstances"][0]["DBInstanceStatus"] != "available":
  
  TypeError: 'NoneType' object has no attribute '__getitem__'
  </code></pre>