Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be used with Windows AWS CLI under Cygwin (fix included) #18

Open
Farmbuyer opened this issue Jul 25, 2023 · 0 comments
Open

Cannot be used with Windows AWS CLI under Cygwin (fix included) #18

Farmbuyer opened this issue Jul 25, 2023 · 0 comments

Comments

@Farmbuyer
Copy link

The easiest way to get the AWS CLI under Cygwin is to simply install the Windows version, and then make sure that the Cygwin PATH picks up the new directory or the automatically-adjusted Windows PATH. However, the Windows AWS CLI uses <CR><LF> line terminators in its text output, which breaks most shell scripts, including delete_vpc.sh.

Under Cygwin, this shows up as an early failure in this bit of code:

# Check VPC status, available or not
state=$(aws ec2 describe-vpcs \
    --vpc-ids "${VPC_ID}" \
    --query 'Vpcs[].State' \
    --region "${AWS_REGION}" \
    --output text)
if [ "${state}" != 'available' ]; then
	echo "The VPC of ${VPC_ID} is ${state}, NOT available now!"
    exit 1
fi

The "state" variable will consist of available\r and fail the comparison test. (Trying to print it to the screen with echo leads to amusing results.)

An easy workaround is to have the shell script run a function for 'aws' calls instead. Just after the test for an installed AWS CLI, I added this:

if [[ "$(uname -s)" == CYGWIN* ]]; then
    aws() {
	    command aws "$@" | tr -d '\r'
    }
fi

and the rest of the shell script required no changes.

Thank you very much for such a useful tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant