For example, if I wish to mount a particular volume that is defined by an environment variable.
I ended up using the following code:
---
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02my_setup.sh":
owner: root
group: root
mode: "000755"
content: |
#!/bin/bash
set -e
. /opt/elasticbeanstalk/hooks/common.sh
EB_CONFIG_APP_CURRENT=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
EB_SUPPORT_FILES_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_files_dir)
# load env vars
eval $($EB_SUPPORT_FILES_DIR/generate_env | sed 's/$/;/')
You can use /opt/elasticbeanstalk/bin/get-config environment
in a bash script
Example:
# .ebextensions/efs_mount.config
commands:
01_mount:
command: "/tmp/mount-efs.sh"
files:
"/tmp/mount-efs.sh":
mode: "000755"
content : |
#!/bin/bash
EFS_REGION=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_REGION')
EFS_MOUNT_DIR=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_MOUNT_DIR')
EFS_VOLUME_ID=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_VOLUME_ID')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With