title: EC2 instance region is not populated in user-data script
body: <p>I want to fill some tags of the EC2 spot instance, however as it is impossible to do it directly in spot request, I do it via user data script. All is going fine when I specify region statically, but it is not universal approach. When I try to detect current region from instance userdata, the <strong>region</strong> variable is always empty. I do it in a following way:</p>
  
  <pre><code>#!/bin/bash
  region=$(ec2-metadata -z | awk '{print $2}' | sed 's/[a-z]$//')
  aws ec2 create-tags \
      --region $region \
      --resources `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id` \
      --tags Key=sometag,Value=somevalue Key=sometag,Value=somevalue
  </code></pre>
  
  <p>I tried to made a delay before region populating</p>
  
  <pre><code>/bin/sleep 30
  </code></pre>
  
  <p>but this had no result.</p>
  
  <p>However, when I run this script manually after start, the tags are added fine. What is going on?</p>
  
  <p>Why all in all aws-cli doesn't get default region from profile? I have <code>aws configure</code> properly configured inside the instance, but without <code>--region</code> clause it throws error that region is not specified.</p>