-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ECR login and add install-awscli script (#332)
- Loading branch information
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
BUILD_DIR=$SCRIPTPATH/../build/ | ||
export PATH="${BUILD_DIR}:${PATH}" | ||
|
||
if [[ -z "${ECR_REGISTRY}" ]]; then | ||
echo "The env var ECR_REGISTRY must be set" | ||
exit 1 | ||
fi | ||
|
||
docker login --username AWS -p="$(docker run --rm --env-file <(env | grep AWS) -i amazon/aws-cli ecr-public get-login-password --region us-east-1)" ${ECR_REGISTRY} | ||
function exit_and_fail() { | ||
echo "❌ Failed to login to ECR Public Repo!" | ||
} | ||
|
||
trap exit_and_fail INT TERM ERR | ||
|
||
"${SCRIPTPATH}/install-awscli" | ||
|
||
docker login --username AWS --password="$(aws ecr-public get-login-password --region us-east-1)" "${ECR_REGISTRY}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
BUILD_DIR=$SCRIPTPATH/../build/ | ||
|
||
VERSION="2.1.13" | ||
os=$(uname) | ||
arch=$(uname -m) | ||
|
||
function exit_and_fail() { | ||
echo "❌ Unable to install awscli v${VERSION} for OS ${os} and arch ${arch}" | ||
} | ||
trap exit_and_fail INT TERM ERR | ||
|
||
if [[ "${os}" = "Linux" ]]; then | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-${arch}-${VERSION}.zip" -o "${BUILD_DIR}/awscliv2.zip" | ||
unzip "${BUILD_DIR}/awscliv2.zip" -d "${BUILD_DIR}/awscliv2" | ||
${BUILD_DIR}/awscliv2/aws/install -i ${BUILD_DIR}/awscliv2 -b "${BUILD_DIR}" | ||
elif [[ "${os}" = "Darwin" ]]; then | ||
curl "https://awscli.amazonaws.com/AWSCLIV2-${VERSION}.pkg" -o "${BUILD_DIR}/awscliv2.pkg" | ||
CHOICES_XML="${BUILD_DIR}/aws-cli-mac.plist" | ||
cat << EOF > "${CHOICES_XML}" | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<array> | ||
<dict> | ||
<key>choiceAttribute</key> | ||
<string>customLocation</string> | ||
<key>attributeSetting</key> | ||
<string>${BUILD_DIR}</string> | ||
<key>choiceIdentifier</key> | ||
<string>default</string> | ||
</dict> | ||
</array> | ||
</plist> | ||
EOF | ||
installer -pkg ${BUILD_DIR}/awscliv2.pkg \ | ||
-target CurrentUserHomeDirectory \ | ||
-applyChoiceChangesXML "${CHOICES_XML}" | ||
ln -s "${BUILD_DIR}/aws-cli/aws" "${BUILD_DIR}/aws" | ||
else # windows | ||
choco install awscli --version ${VERSION} --force -y || : | ||
fi | ||
|
||
echo "✅ Install AWS CLI v${VERSION} for OS ${os} and arch ${arch}" |
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
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