title: How do I access EC2 instance ID in ASP.NET Core?
body: <p>I have an ASP.Net Core application hosted in an AWS Load Balance setup with x number of instances. </p>
  
  <p>I what to display which EC2 instance actually serving the request on the bottom of the web page.</p>
  
  <p>Is there a Nuget package or an convenient API solution to achive this ?</p>
  
  <p>There is a question on Stackoverflow since 2009:  <a href="https://stackoverflow.com/questions/625644/find-out-the-instance-id-from-within-an-ec2-machine">Find out the instance id from within an ec2 machine</a> that provides a solution using wget to call <a href="http://169.254.169.254/latest/meta-data/instance-id" rel="nofollow noreferrer">http://169.254.169.254/latest/meta-data/instance-id</a> to get the instance-id</p>
  
  <p>I was hoping for a Nuget package or an API like solution to achieve this.</p>
  
  <p><strong>Update - Solution</strong></p>
  
  <p>The <a href="https://github.com/aws/aws-sdk-net/" rel="nofollow noreferrer">AWSSDK.Core</a> (The Amazon Web Services SDK for .NET - Core Runtime) has the <code>Amazon.Util.EC2InstanceMetadata</code> class which has the InstanceId propery which allows clean cut access to the information I needed.</p>
  
  <p>Thanks for pointing me in the right direction <a href="https://stackoverflow.com/users/5451492/rodrigo-m">rodrigo-m</a>.</p>