<p>I am running a kubernetes cluster on AWS-ec2 and I would like to have the pod (container) know during runtime which region it's running on, how can this be done?</p>

<p>Take a look at AWS <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-retrieval" rel="nofollow noreferrer">Instance Metadata</a>:</p>

<blockquote>
  <p>[...] instance metadata is available from your running instance, you
  do not need to use the Amazon EC2 console or the AWS CLI. This can be
  helpful when you're writing scripts to run from your instance</p>
</blockquote>

<p>You can query the region of a given container querying the metadata from inside during runtime. Like this:</p>

<pre><code>curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone
</code></pre>

<blockquote>
  <p><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories" rel="nofollow noreferrer">placement/availability-zone</a>: The Availability Zone in which the instance launched.</p>
</blockquote>
