We want to be able to retrieve the elastic beanstalk application version in our PHP code. I don't see that EB passes it to us in any server configuration files, which I find it strange. Does anyone else know how we might be able to get this?
相关问题
- How to generate 12 digit unique number in redshift
- Use awslogs with kubernetes 'natively'
- Assume/switch role in aws toolkit for eclipse 2.0
- 'no SavedModel bundles found!' on tensorfl
- Installing Python dependencies in AWS Codestar wit
相关文章
- Right way to deploy Rails + Puma + Postgres app to
- how many objects are returned by aws s3api list-ob
- AWS S3 in rails - how to set the s3_signature_vers
- Passthrough input to output in AWS Step Functions
- I cannot locate production log files on Elastic Be
- ImportError: cannot import name 'joblib' f
- Static IP for Auto Scale in AWS
- Step function exceeding the maximum number of char
In PHP application, you can get it using
aws elasticbeanstalk describe-environments --environment-names <environment-name>
You should add the below environment variables in the php script to get it working.
AWS_DEFAULT_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
I have used
putenv()
function to set the environment variables andshell_exec()
to get the json output. Parsed the json output to get theVersionLabel
which is the actual application version.While the best way is really to ask AWS directly:
I've had limited success deducing the same 4 or 5 digit hash by using:
tail /var/log/eb-activity.log | grep -i "\[Application update .*\] : Completed activity." | tail -1 | sed -E 's/.*Application update (.*)@.*/\1/'
Outputs the actual app version ID like
app-2.15.0-31-gf4a2918
in our case.This works from inside any EB EC2, requires no API hit or git repo (some deploy by zip). Useful for sending a notification about a recent deployment.
Consolidating on the answers from @Georgij and @IanBlenke here are the ways you can find the version.
1. Most Reliable (Manifest)
You can
sudo cat /opt/elasticbeanstalk/deploy/manifest
Output:
2. You can look at the eb-activity logs
Secondly you could look at the eb-activity logs. This will only show you in the log line... You have to assume it's been a successful installation too..
tail /var/log/eb-activity.log | grep -i "app-.*@"
At least for Docker containers - you can use the information stored in
/opt/elasticbeanstalk/deploy/manifest
.I've just been looking for a solution myself.
For now, at least, the following works:
To elaborate,
$EB_CONFIG_SOURCE_BUNDLE
contains a path to the zip archive of your application (i.e./opt/elasticbeanstalk/deploy/appsource/source_bundle
). The version tag is embedded as a comment in this file.