Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
933 views
in Technique[技术] by (71.8m points)

amazon web services - Referencing env variables from Elastic Beanstalk .ebextensions config files

Is it posssible to reference the PARAM1 / PARAM2 etc.. container environment properties from the .ebextensions config files. If so, how? I tried $PARAM1 but it seemed to be an empty value.

I want to set the hostname on startup to contain DEV, QA or PROD, which I pass to my container via the PARAM1 environment variable.

commands:
  01-set-correct-hostname:
    command: hostname myappname{$PARAM1}.com
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It turns out you can only do this in the container_commands section, not the commands section.

This works:

container_commands:
  01-set-correct-hostname:
    command: "hostname myappname{$PARAM1}.com"

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands for more details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...