lundi 7 septembre 2015

How can I set a per-instance env variable for an elastic beanstalk docker container?

Our elastic single-container beanstalk docker application runs as load balanced with multiple ec2 instances.

I want to pass the ec2 instance id of the machine it's running on as an environment variable to the docker container. (I want to avoid doing AWS specific stuff inside the container).

I figure I need to put something in an .ebextension config file, where I do a curl to get the instance data and then set it into an environment variable that will be passed to the docker container.

Something like this (which doesn't work; it doesn't cause EB errors, but the env var is not available inside the container):

container_commands:
  set_instance_id:
    command: export EC2_INSTANCE_ID=`curl -s http://ift.tt/N6UOsk`

Ideally, I'd like to avoid hacking the EB run scripts, because they're undocumented and seem to change without notice.




Aucun commentaire:

Enregistrer un commentaire