title: IAM Role Attached to Instance "Unable to Locate Credentials" - Can't hit metadata endpoint
body: <p>I am working with an EC2 instance with a custom Ubuntu 16.04 AMI.</p>
  
  <p>I'm attempting to migrate to using an IAM role attached to the instance for accessing S3.</p>
  
  <p>I have created a simple test role with the following permissions:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [
          {
              "Effect": "Allow",
              "Action": "s3:*",
              "Resource": "*"
          }
      ]
  }
  </code></pre>
  
  <p>and the following policy document:</p>
  
  <pre><code>{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "ec2.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }
  </code></pre>
  
  <p>This was attached to an already running EC2 instance.</p>
  
  <p>On the EC2 instance, I tested out the CLI in a couple of different ways, and I'm getting surprising results.</p>
  
  <pre><code>ubuntu@machine:~$ aws s3 ls
  Unable to locate credentials. You can configure credentials by running "aws configure".
  </code></pre>
  
  <pre><code>ubuntu@machine:~$ aws configure list
        Name                    Value             Type    Location
        ----                    -----             ----    --------
     profile                &lt;not set&gt;             None    None
  access_key                &lt;not set&gt;             None    None
  secret_key                &lt;not set&gt;             None    None
      region                &lt;not set&gt;             None    None
  </code></pre>
  
  <p>I then went to check the metadata endpoint to confirm the role is attached, but ran into some issues.  My suspicion is this is the root of the problem, but I've never seen this before - an inability to access the metadata endpoint.  Does anyone know what might be blocking this or why this is unavailable?</p>
  
  <pre><code>ubuntu@machine:~$ curl http://169.254.169.254/latest/meta-data/
  curl: (7) Couldn't connect to server
  </code></pre>
  
  <p>Many Thanks</p>