aws-samples / ec2-classic-resource-finder

This script enables the identification of resources running in Amazon EC2 Classic
MIT No Attribution
131 stars 81 forks source link

Space in EB App Name cause incorrect data #19

Closed rob-showit closed 2 years ago

rob-showit commented 3 years ago

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

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

TheScottMo commented 2 years ago

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.