Cloud9 normally manages IAM credentials dynamically. This isn’t currently compatible with some AWS services authentication, so we will disable it and rely on the IAM role instead.
Let’s run the commands below, the following actions will take place as we do that:
🔹 Remove any existing AWS credentials file
🔹 Set the region to work with our desired region
🔹 Validate that our IAM role is valid
rm -vf ${HOME}/.aws/credentials
export AWS_REGION=$(ec2-metadata -z | awk '{print $2}' | sed 's/[a-z]$//')
echo "export AWS_REGION=${AWS_REGION}" | tee -a ~/.bash_profile
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
echo "export ACCOUNT_ID=${ACCOUNT_ID}" | tee -a ~/.bash_profile
aws configure set default.region ${AWS_REGION}
aws sts get-caller-identity --query Arn | grep Logz-io-Workshop-Admin -q && echo "IAM role valid" || echo "IAM role NOT valid"
If the IAM role is not valid, DO NOT PROCEED. Go back and confirm the steps on this page.