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

Update aws cli to v2 #230

Merged
merged 6 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions code/solutions/cloud9/awscliv2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Check system architecture
ARCH=$(uname -m)
if [ "$ARCH" == "x86_64" ]
then
AWSCLI_PKG="awscli-exe-linux-x86_64.zip"
elif [ "$ARCH" == "aarch64" ]
then
AWSCLI_PKG="awscli-exe-linux-aarch64.zip"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi

# Check if awscli version 1 is installed
if yum list installed | grep awscli &> /dev/null
then
echo "awscli version 1 is installed, removing..."
# Uninstall awscli version 1
sudo yum remove -y awscli
fi

# Install awscli version 2
curl "https://awscli.amazonaws.com/$AWSCLI_PKG" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install

# Print awscli version
aws --version

# Clean up
rm -f awscliv2.zip
rm -rf aws/
28 changes: 28 additions & 0 deletions content/prerequisites/cloud9/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ We recommend using **us-east-1 (N. Virginia)** as the _AWS Region_ for the works
If you have issues using the Cloud9 environment, please see the [Troubleshooting AWS Cloud9](https://docs.aws.amazon.com/cloud9/latest/user-guide/troubleshooting.html) page in the user guide.
:::

### Install the latest version of AWS CLI

Cloud9 Instance comes pre-installed with [AWS CLI version 1](https://docs.aws.amazon.com/cli/v1/userguide/install-linux-al2017.html). For the workshop we require to use [AWS CLI version 2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
To make the [migration](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration-instructions.html) from version 1 to version 2 easier, you can use the script provided.

The script will:
* Check for system architecture to download correct bundle.
* Check if the AWS CLI version 1 is installed, and if yes removes it.
* Installs AWS CLI version 2.
* Cleans up installation files.

1. In the **Cloud9 terminal** navigate to `cfn101-workshop/code/solutions/cloud9`:
:::code{language=shell showLineNumbers=false showCopyAction=true}
cd cfn101-workshop/code/solutions/cloud9
:::
1. Make the script executable:
:::code{language=shell showLineNumbers=false showCopyAction=true}
chmod +x awscliv2.sh
:::
1. Run the script:
:::code{language=shell showLineNumbers=false showCopyAction=true}
source awscliv2.sh
:::
1. Check that the installation was successful, and you have the latest version of AWS CLI:
:::code{language=shell showLineNumbers=false showCopyAction=true}
aws --version
:::

### Clone lab resources using `git`
rezabekf marked this conversation as resolved.
Show resolved Hide resolved
Clone the repository to your working directory. In the Cloud9 terminal run:

Expand Down
Loading