Example App name: "Webserver App"
Example Env Name: "webserver-app-a"
In the script, currently, the delimiter being used for cut is ' ' (space)
for ebenvapp in jq -r '.Environments[] | .ApplicationName +" "+ .EnvironmentName' <<< $ebappraw 2>> errors.txt ## Loop over each application and environment pair
do
ebapp=cut -d " " -f1 <<< $ebenvapp 2>> errors.txt ## Extract the Application name
ebenv=cut -d " " -f2 <<< $ebenvapp 2>> errors.txt ## Extract the Environment name
this results in ebapp: "Webserver" & ebenv: "App"
Changing this to delimiter of ':' (colon) is a possible fix tested in our environment with spaces.
for ebenvapp in jq -r '.Environments[] | .ApplicationName +":"+ .EnvironmentName' <<< $ebappraw 2>> errors.txt ## Loop over each application and environment pair
do
ebapp=cut -d ':' -f1 <<< $ebenvapp 2>> errors.txt ## Extract the Application name
ebenv=cut -d ':' -f2 <<< $ebenvapp 2>> errors.txt ## Extract the Environment name
this results in ebapp: "Webserver App" & ebenv: "webserver-app-a"
-Not sure if this is necessary, but in the next line I also put double quotes ("") around the $ebapp
ebnsval=aws elasticbeanstalk describe-configuration-settings --application-name **"$ebapp"** --environment-name $ebenv --query 'ConfigurationSettings[*].OptionSettings[?Namespace==\aws:ec2:vpc`&&OptionName==`VPCId`&&Value!=`null`].OptionName' --region $region --output text 2>> errors.txt` ## If the environment is configured for a vpc return "VPCId"
I have released Version 2 today, which runs in Python and handles these as dictionaries instead of complex string parsing in bash. This will resolve this issue. Thank you for the feedback.
Example App name: "Webserver App" Example Env Name: "webserver-app-a"
In the script, currently, the delimiter being used for cut is ' ' (space) for ebenvapp in
jq -r '.Environments[] | .ApplicationName +" "+ .EnvironmentName' <<< $ebappraw 2>> errors.txt
## Loop over each application and environment pair do ebapp=cut -d " " -f1 <<< $ebenvapp 2>> errors.txt
## Extract the Application name ebenv=cut -d " " -f2 <<< $ebenvapp 2>> errors.txt
## Extract the Environment nameChanging this to delimiter of ':' (colon) is a possible fix tested in our environment with spaces. for ebenvapp in
jq -r '.Environments[] | .ApplicationName +":"+ .EnvironmentName' <<< $ebappraw 2>> errors.txt
## Loop over each application and environment pair do ebapp=cut -d ':' -f1 <<< $ebenvapp 2>> errors.txt
## Extract the Application name ebenv=cut -d ':' -f2 <<< $ebenvapp 2>> errors.txt
## Extract the Environment namethis results in ebapp: "Webserver App" & ebenv: "webserver-app-a"
-Not sure if this is necessary, but in the next line I also put double quotes ("") around the $ebapp ebnsval=
aws elasticbeanstalk describe-configuration-settings --application-name **"$ebapp"** --environment-name $ebenv --query 'ConfigurationSettings[*].OptionSettings[?Namespace==\
aws:ec2:vpc`&&OptionName==`VPCId`&&Value!=`null`].OptionName' --region $region --output text 2>> errors.txt` ## If the environment is configured for a vpc return "VPCId"