You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.0 KiB
Bash
109 lines
3.0 KiB
Bash
5 years ago
|
#!/usr/bin/env bash
|
||
5 years ago
|
# vim:ts=4:sts=4:sw=4:et
|
||
5 years ago
|
#
|
||
|
# Author: Hari Sekhon
|
||
|
# Date: 2019-09-19 11:26:11
|
||
|
# (moved from Makefile)
|
||
|
#
|
||
2 years ago
|
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||
5 years ago
|
#
|
||
|
# License: see accompanying LICENSE file
|
||
|
#
|
||
2 years ago
|
# https://www.linkedin.com/in/HariSekhon
|
||
5 years ago
|
#
|
||
|
|
||
2 years ago
|
# Installs AWS CLI, eksctl and ECS CLI
|
||
5 years ago
|
|
||
|
# You might need to first:
|
||
|
#
|
||
|
# yum install -y epel-release
|
||
|
# yum install -y gcc git make python-pip which
|
||
|
#
|
||
|
# this is automatically done first when called via 'make aws' at top level of this repo
|
||
|
|
||
|
set -euo pipefail
|
||
|
[ -n "${DEBUG:-}" ] && set -x
|
||
3 years ago
|
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
5 years ago
|
|
||
3 years ago
|
# shellcheck disable=SC1090,SC1091
|
||
3 years ago
|
. "$srcdir/../lib/utils.sh"
|
||
3 years ago
|
|
||
|
# shellcheck disable=SC1090,SC1091
|
||
4 years ago
|
. "$srcdir/../lib/ci.sh"
|
||
|
|
||
2 years ago
|
section "Installing AWS CLI"
|
||
5 years ago
|
|
||
5 years ago
|
mkdir -p ~/bin
|
||
|
|
||
4 years ago
|
# unreliable that HOME is set, ensure shell evaluates to the right thing before we use it
|
||
|
[ -n "${HOME:-}" ] || HOME=~
|
||
4 years ago
|
|
||
5 years ago
|
export PATH="$PATH:/usr/local/bin"
|
||
5 years ago
|
export PATH="$PATH:$HOME/bin"
|
||
5 years ago
|
|
||
2 years ago
|
#if type -P aws &>/dev/null; then
|
||
|
# echo "AWS CLI already installed"
|
||
1 year ago
|
if type -P apk &>/dev/null; then
|
||
|
if ! grep -q 'https://dl-cdn.alpinelinux.org/alpine/edge/testing' /etc/apk/repositories; then
|
||
|
echo -e -n "\n@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
|
||
|
fi
|
||
|
apk add aws-cli-v2@testing --no-cache
|
||
|
else
|
||
5 years ago
|
echo "Installing AWS CLI"
|
||
3 years ago
|
# old AWS CLI v1 - doesn't support AWS SSO
|
||
1 year ago
|
#PYTHON_USER_INSTALL=1 "$srcdir/../python/python_pip_install.sh" awscli
|
||
3 years ago
|
pushd /tmp
|
||
|
#curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
|
||
3 years ago
|
#wget -c "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip"
|
||
|
#unzip -o awscli-bundle.zip
|
||
3 years ago
|
# needs to find Python 3 first in the path to work
|
||
3 years ago
|
#PATH="/usr/local/opt/python/libexec/bin:$PATH" ./awscli-bundle/install -b ~/bin/aws
|
||
|
if is_mac; then
|
||
|
wget -c "https://awscli.amazonaws.com/AWSCLIV2.pkg" -O "AWSCLIV2.pkg"
|
||
3 years ago
|
# defined in utils.sh lib
|
||
|
# shellcheck disable=SC2154
|
||
|
$sudo installer -pkg AWSCLIV2.pkg -target /
|
||
2 years ago
|
rm -fr -- AWSCLIV2.pkg
|
||
3 years ago
|
else
|
||
|
wget -c "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O "awscliv2.zip"
|
||
|
unzip -o awscliv2.zip
|
||
3 years ago
|
# defined in utils.sh lib
|
||
|
# shellcheck disable=SC2154
|
||
2 years ago
|
$sudo ./aws/install --update
|
||
2 years ago
|
rm -fr -- aws awscliv2.zip
|
||
3 years ago
|
fi
|
||
3 years ago
|
popd
|
||
5 years ago
|
echo
|
||
2 years ago
|
echo -n "AWS CLI version: "
|
||
|
aws --version
|
||
|
echo
|
||
1 year ago
|
fi
|
||
5 years ago
|
|
||
4 years ago
|
"$srcdir/install_eksctl.sh"
|
||
|
|
||
5 years ago
|
if type -P ecs-cli &>/dev/null; then
|
||
|
echo "ECS CLI already installed"
|
||
|
else
|
||
|
echo "Installing AWS ECS CLI"
|
||
3 years ago
|
if is_mac; then
|
||
5 years ago
|
wget -O ~/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-darwin-amd64-latest
|
||
|
else
|
||
|
wget -O ~/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
|
||
|
fi
|
||
|
chmod +x ~/bin/ecs-cli
|
||
|
fi
|
||
|
|
||
5 years ago
|
# AWS CLI usually installs to ~/.local/bin/aws on Linux or ~/Library/Python/2.7/bin on Mac
|
||
|
|
||
5 years ago
|
cat <<EOF
|
||
5 years ago
|
|
||
5 years ago
|
Done
|
||
5 years ago
|
|
||
5 years ago
|
Installed locations:
|
||
5 years ago
|
|
||
5 years ago
|
$(type -P aws)
|
||
4 years ago
|
$(type -P ecs-cli)
|
||
4 years ago
|
$(type -P eksctl)
|
||
5 years ago
|
|
||
|
EOF
|