-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Offer self-service IDE based on VSCode (#1044)
- Loading branch information
1 parent
0ceb846
commit a0bfe8a
Showing
61 changed files
with
1,633 additions
and
140 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,19 +24,6 @@ jobs: | |
- name: Install utilities | ||
run: | | ||
sudo apt install -y gettext | ||
mkdir -p ${HOME}/.local/bin | ||
wget https://github.com/jckuester/awsweeper/releases/download/v0.12.0/awsweeper_0.12.0_linux_amd64.tar.gz | ||
tar zxf awsweeper_0.12.0_linux_amd64.tar.gz | ||
mv awsweeper_0.12.0_linux_amd64/awsweeper ${HOME}/.local/bin | ||
wget https://github.com/eksctl-io/eksctl/releases/download/v0.169.0/eksctl_Linux_amd64.tar.gz | ||
tar zxf eksctl_Linux_amd64.tar.gz | ||
mv eksctl ${HOME}/.local/bin | ||
chmod +x ${HOME}/.local/bin/* | ||
echo "${HOME}/.local/bin" >> $GITHUB_PATH | ||
- name: Get AWS credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
|
@@ -50,13 +37,4 @@ jobs: | |
CLUSTER_ID: ${{ github.event.inputs.clusterId }} | ||
AWS_REGION: "${{ secrets.AWS_REGION }}" | ||
run: | | ||
export CLEANUP_ENVIRONMENT_NAME="$CLUSTER_ID" | ||
export AWS_DEFAULT_REGION="$AWS_REGION" | ||
envsubst < hack/lib/filter.yml > filter.yml | ||
cat filter.yml | ||
awsweeper --force filter.yml | ||
make destroy-infrastructure environment="$CLUSTER_ID" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
output_path=$1 | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
if [ -z "$output_path" ]; then | ||
outfile=$(mktemp) | ||
else | ||
outfile=$output_path | ||
fi | ||
|
||
cd lab | ||
|
||
export Env="${EKS_CLUSTER_NAME}" | ||
|
||
cat cfn/eks-workshop-vscode-cfn.yaml | yq '(.. | select(has("file"))) |= (load(.file))' | envsubst '$Env' > $outfile | ||
|
||
echo "Output file: $outfile" |
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,24 @@ | ||
#!/bin/bash | ||
|
||
environment=$1 | ||
|
||
set -Eeuo pipefail | ||
set -u | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
bash $SCRIPT_DIR/update-iam-role.sh $environment | ||
|
||
sleep 5 | ||
|
||
cluster_exists=0 | ||
aws eks describe-cluster --name "${EKS_CLUSTER_NAME}" &> /dev/null || cluster_exists=$? | ||
|
||
if [ $cluster_exists -eq 0 ]; then | ||
echo "Cluster ${EKS_CLUSTER_NAME} already exists" | ||
else | ||
echo "Creating cluster ${EKS_CLUSTER_NAME}" | ||
bash $SCRIPT_DIR/exec.sh "${environment}" 'cat /cluster/eksctl/cluster.yaml | envsubst | eksctl create cluster -f -' | ||
fi |
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,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
outfile=$(mktemp) | ||
|
||
bash $SCRIPT_DIR/build-ide-cfn.sh $outfile | ||
|
||
aws cloudformation deploy --stack-name eks-workshop-ide1 \ | ||
--capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-file $outfile |
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,24 @@ | ||
#!/bin/bash | ||
|
||
environment=$1 | ||
|
||
set -Eeuo pipefail | ||
set -u | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
cluster_exists=0 | ||
aws eks describe-cluster --name "${EKS_CLUSTER_NAME}" &> /dev/null || cluster_exists=$? | ||
|
||
if [ $cluster_exists -eq 0 ]; then | ||
echo "Deleting cluster ${EKS_CLUSTER_NAME}" | ||
bash $SCRIPT_DIR/shell.sh "${environment}" 'delete-environment || true' | ||
|
||
bash $SCRIPT_DIR/exec.sh "${environment}" 'eksctl delete cluster --name ${EKS_CLUSTER_NAME} --region ${AWS_REGION} --wait --force --disable-nodegroup-eviction --timeout 45m' | ||
else | ||
echo "Cluster ${EKS_CLUSTER_NAME} does not exist" | ||
fi | ||
|
||
aws cloudformation delete-stack --stack-name ${EKS_CLUSTER_NAME}-ide-role || true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
environment=$1 | ||
|
||
set -Eeuo pipefail | ||
set -u | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
aws resourcegroupstaggingapi get-resources --tag-filters Key=env,Values=$EKS_CLUSTER_NAME --query 'ResourceTagMappingList[].ResourceARN' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
aws_credential_args="" | ||
echo "Generating temporary AWS credentials..." | ||
|
||
ASSUME_ROLE=${ASSUME_ROLE:-""} | ||
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-""} | ||
session_suffix=$(openssl rand -hex 4) | ||
|
||
target_role=${IDE_ROLE_ARN} | ||
|
||
if [ ! -z "$AWS_ACCESS_KEY_ID" ]; then | ||
echo "Using environment AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY" | ||
ASSUME_ROLE=${ASSUME_ROLE:-""} | ||
|
||
aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" | ||
elif [ ! -z "$ASSUME_ROLE" ]; then | ||
echo "Generating temporary AWS credentials..." | ||
if [ ! -z "$ASSUME_ROLE" ]; then | ||
echo "Assuming role $ASSUME_ROLE" | ||
target_role=$ASSUME_ROLE | ||
fi | ||
|
||
ACCESS_VARS=$(aws sts assume-role --role-arn $ASSUME_ROLE --role-session-name ${EKS_CLUSTER_NAME}-shell --output json | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId) AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey) AWS_SESSION_TOKEN=\(.SessionToken)"') | ||
ACCESS_VARS=$(aws sts assume-role --role-arn ${target_role} --role-session-name ${EKS_CLUSTER_NAME}-shell-${session_suffix} --output json | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId) AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey) AWS_SESSION_TOKEN=\(.SessionToken)"') | ||
|
||
# TODO: This should probably not use eval | ||
eval "$ACCESS_VARS" | ||
# TODO: This should probably not use eval | ||
eval "$ACCESS_VARS" | ||
|
||
aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" | ||
else | ||
echo "Inheriting credentials from instance profile" | ||
fi | ||
aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
environment=$1 | ||
|
||
set -Eeuo pipefail | ||
set -u | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
outfile=$(mktemp) | ||
|
||
cd lab | ||
|
||
export Env="${EKS_CLUSTER_NAME}" | ||
|
||
cat iam/iam-role-cfn.yaml | yq '(.. | select(has("file"))) |= (load(.file))' | envsubst '$Env' > $outfile | ||
|
||
aws cloudformation deploy \ | ||
--stack-name ${EKS_CLUSTER_NAME}-ide-role \ | ||
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \ | ||
--template-file $outfile |
Oops, something went wrong.