Amazon-ECS [SOLVED]: Self describe regions with ECS/EC2 Instance

Amazon-ECS [SOLVED]: Self describe regions with ECS/EC2 Instance

Home Forums Amazon Web Services Amazon ECS Amazon-ECS [SOLVED]: Self describe regions with ECS/EC2 Instance

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #166032

    Cloudy Point
    Keymaster

    QuestionQuestion

    I want to securely fetch configuration files from S3 using a secure VPC from my Docker container. But I want to determine inside the application which configuration file to fetch and use based on the region I am on. Is there a good/best practice to go on about describing the current container’s region?

    I understand that you can use the AWS SDK/CLI to describe the ECS instances, but that doesn’t tell me which one the container is specifically deployed on.

    #166033

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    Within EC2, you can retrieve the instance metadata using a simple curl command to a local (internal) web API. Region and AZ are some of the data points you can get:

    http://169.254.169.254/latest/meta-data/services/domain
    http://169.254.169.254/latest/meta-data/placement/availability-zone
    

    See this page for full details about instance metadata.

    Within ECS, I’d be interested to see if these might still work — my hunch is they would, as the container should query the host machine’s API for the answer, and the ECS host is most certainly an EC2 instance.

    Let us know if that works?

    Source: https://stackoverflow.com/questions/45167488/self-describe-regions-with-ecs-ec2-instance
    Author: Neal
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.