Giter VIP home page Giter VIP logo

imds-credential-server's Introduction

imds-credential-server

Provide AWS credentials to a container from the host

This CLI tool runs a server compliant with the EC2 IMDSv2 interface in order to vend AWS credentials, primarily to export credentials into locally-run containers.

This is better than mounting your ~/.aws directory into a container as a) it allows for mechanisms that only work on the host, e.g., custom credential processes and b) it only vends one set of (refreshable) credentials to the container rather than providing access to all your credentials.

Install

Three options:

$ go install github.com/benkehoe/imds-credential-server@main
  • Clone the repo
$ git clone https://github.com/benkehoe/imds-credential-server
$ cd imds-credential-server && go build .

Use

Run the server in one terminal. It needs to have credentials available to it in the normal manner; the --profile option works as you'd expect.

It will bind to localhost by default, if you need something different use the HOST:PORT format.

$ imds-credential-server 8081

And then run a container in a separate terminal. Note the trailing slash on the URL.

$ docker run --rm -p 8081:8081 -e AWS_EC2_METADATA_SERVICE_ENDPOINT=http://host.docker.internal:8081/ amazon/aws-cli sts get-caller-identity
{
    "UserId": "AROAXXXXXXXXXXXXXXXXX:SessionName",
    "Account": "123456789012",
    "Arn": "arn:aws:sts::123456789012:assumed-role/SomeRole/SessionName"
}

Details

You must provide a port (or optionally a full address) for the server. Then map the port from the host to the container, and set the environment variable AWS_EC2_METADATA_SERVICE_ENDPOINT to http://host.docker.internal:MAPPED_PORT/ with the approporiate port and remember to include the trailing slash (the CLI and some SDKs won't work correctly without it).

AWS SDKs run inside the container should just work, as should any tool that relies on them. For tools that don't correctly accept the full range of AWS credential sources, check out aws-export-credentials, ideally using it inside the container.

You can use imds-credential-server version to get the version (this project uses monotonic versioning).

imds-credential-server's People

Contributors

benkehoe avatar bweisshaar-benchling avatar ravenium avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.