Last active
October 4, 2021 14:48
-
-
Save rcarrata/e8afe638bd18244a2e934b949c25ac93 to your computer and use it in GitHub Desktop.
Install AWS and set up AWS Credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "## Please give me the AWSKEY" | |
read AWSKEY | |
echo "## Please give me the AWS_SECRET_KEY" | |
read AWSSECRETKEY | |
echo "## Please give me the REGION" | |
read REGION | |
aws --version &> /dev/null | |
if [ $? == 0 ]; then | |
echo "AWS Already installed" | |
aws --version | |
else | |
echo "## Download the AWS CLI" | |
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" | |
unzip awscli-bundle.zip | |
echo "## Download the AWS CLI" | |
./awscli-bundle/install -i /usr/local/aws -b /bin/aws | |
echo "## Checking the versio" | |
/bin/aws --version | |
fi | |
echo "## Backup and remove preexistent creds" | |
cp -pr $HOME/.aws /tmp | |
rm -rf $HOME/.aws | |
mkdir $HOME/.aws | |
echo "## Installing the new creds" | |
cat << EOF > $HOME/.aws/credentials | |
[default] | |
aws_access_key_id = ${AWSKEY} | |
aws_secret_access_key = ${AWSSECRETKEY} | |
region = $REGION | |
EOF | |
echo "## Testing aws cli" | |
aws sts get-caller-identity |
Author
rcarrata
commented
Oct 4, 2021
- Tested and working in aws bastion instance :
- Running the aws set credentials:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment