Last active
August 20, 2024 20:32
-
-
Save pahud/1b932d905549851a6f5d0385712da275 to your computer and use it in GitHub Desktop.
My AWS SSO setup script for Gitpod workspaces
This file contains hidden or 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
# watch the demo at https://youtu.be/cGUNf1FMNvI | |
# | |
# customize these variables | |
# | |
DEFAULT_PROFILE='default' | |
DEFAULT_REGION='us-east-1' | |
DEFAULT_OUTPUT='json' | |
SSO_START_URL='https://your-sso.awsapps.com/start' | |
SSO_REGION='us-east-1' | |
SSO_ACCOUNT_ID='123456789012' | |
SSO_ROLE_NAME='AdministratorAccess' | |
# | |
# default variables | |
# | |
KUBECTL_URL='https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/amd64/kubectl' | |
AWS_CLI_V2_URL='https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' | |
PROJECT_DIR="${PWD}" | |
GITPOD_LOCAL_BIN='/home/gitpod/.local/bin' | |
# install aws-cli v2 | |
mkdir /tmp/awscliv2 && cd /tmp/awscliv2 | |
curl "${AWS_CLI_V2_URL}" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install -b /usr/local/bin --update | |
rm -rf /tmp/awscliv2 | |
cd $OLDPWD | |
aws --version | |
# install kubectl | |
curl -o kubectl "${KUBECTL_URL}" && \ | |
chmod +x kubectl && \ | |
mv kubectl ${GITPOD_LOCAL_BIN} | |
echo "generate the ~/.aws/config" | |
mkdir -p ~/.aws | |
cat << EOF > ~/.aws/config | |
[${DEFAULT_PROFILE}] | |
sso_session = sso | |
sso_account_id = ${SSO_ACCOUNT_ID} | |
sso_role_name =${SSO_ROLE_NAME} | |
region = ${DEFAULT_REGION} | |
output = ${DEFAULT_OUTPUT} | |
[sso-session sso] | |
sso_start_url = ${SSO_START_URL} | |
sso_region = ${SSO_REGION} | |
sso_registration_scopes = sso:account:access | |
EOF | |
# login to authenticate again | |
#aws sso login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this useful script. I have a question...
What is the use of kubectl in the script?