Skip to content

Commit 1d92de7

Browse files
committed
feat: Added Setup in learning paths with a few life improvements fixes
1 parent 0ca9b00 commit 1d92de7

38 files changed

Lines changed: 282 additions & 2080 deletions

File tree

hack/destroy-infrastructure.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ wait
3939
# Only delete ide-role if all clusters are deleted
4040
if [ "$cluster" == "all" ]; then
4141
aws cloudformation delete-stack --stack-name ${EKS_CLUSTER_NAME}-ide-role || true
42+
echo "Deleted role"
4243
fi

hack/exec.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ container_image='eks-workshop-environment'
1919

2020
(cd $SCRIPT_DIR/../lab && $CONTAINER_CLI build -q -t $container_image .)
2121

22-
echo "Checking SKIP: $SKIP_CREDENTIALS"
22+
2323
if [ -z "$SKIP_CREDENTIALS" -a -z "$USE_CURRENT_USER" ]; then
24+
echo "Passing temp AWS credentials"
2425
source $SCRIPT_DIR/lib/generate-aws-creds.sh
2526
elif [ -n "${USE_CURRENT_USER:-}" ]; then
2627
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
27-
echo "No role credentials found, please check your AWS credentials"
28+
echo "No AWS_ACCESS_KEY_ID found, please check your AWS credentials"
2829
exit 1
2930
fi
31+
echo "Using USE_CURRENT_USER"
3032
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"
3133
else
34+
echo "Using DEFAULT no credentials passed"
3235
aws_credential_args=""
3336
fi
3437

@@ -38,5 +41,6 @@ $CONTAINER_CLI run --rm \
3841
-v $SCRIPT_DIR/../manifests:/manifests \
3942
-v $SCRIPT_DIR/../cluster:/cluster \
4043
--entrypoint /bin/bash \
44+
-e "RESET_NO_DELETE=true" \
4145
-e 'EKS_CLUSTER_NAME' -e 'EKS_CLUSTER_AUTO_NAME' -e 'AWS_REGION' -e 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' -e RESOURCE_CODEBUILD_ROLE_ARN \
4246
$aws_credential_args $container_image -c "$shell_command"

hack/shell.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fi
4040
$CONTAINER_CLI run --rm $interactive_args $dns_args \
4141
-v $SCRIPT_DIR/../manifests:/eks-workshop/manifests \
4242
-v $SCRIPT_DIR/../cluster:/cluster \
43+
-e "RESET_NO_DELETE=true" \
4344
-e 'EKS_CLUSTER_NAME' -e 'EKS_CLUSTER_AUTO_NAME' -e 'AWS_REGION' \
4445
-p 8889:8889 \
4546
$aws_credential_args $container_image $shell_command

lab/bin/reset-environment

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
GREEN='\033[1;32m'
46
RED='\033[1;31m'
57
PURPLE='\033[1;35m'
@@ -41,8 +43,8 @@ fi
4143
rm -f /home/ec2-user/.kube/config
4244
EKS_CLUSTER_AUTO_NAME=${EKS_CLUSTER_AUTO_NAME:-"eks-workshop-auto"}
4345

44-
aws eks update-kubeconfig --name $EKS_CLUSTER_AUTO_NAME --alias eks-workshop-auto
45-
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --alias default --user-alias default
46+
aws eks update-kubeconfig --name $EKS_CLUSTER_AUTO_NAME --alias eks-workshop-auto 2>/dev/null || true
47+
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --alias default --user-alias default 2>/dev/null || true
4648

4749
module=$1
4850

@@ -66,10 +68,13 @@ mkdir -p /eks-workshop
6668
logmessage "🚀 We're preparing your environment for the next lab, sit tight!"
6769

6870
REPOSITORY_REF=${REPOSITORY_REF:-""}
71+
RESET_NO_DELETE=${RESET_NO_DELETE:-""}
6972

7073
if [ ! -z "${REPOSITORY_REF}" ]; then
7174
rm -f /home/ec2-user/environment/eks-workshop
72-
rm -rf $manifests_path
75+
if [ -z "${RESET_NO_DELETE}" ]; then
76+
rm -rf $manifests_path
77+
fi
7378
rm -rf $repository_path
7479

7580
logmessage "📦 Refreshing copy of workshop repository from GitHub..."
@@ -78,7 +83,12 @@ if [ ! -z "${REPOSITORY_REF}" ]; then
7883

7984
logmessage ""
8085

81-
cp -R $repository_path/manifests $manifests_path
86+
# In containers we cannot delete the base path so we need to copy inside
87+
for dir in $repository_path/manifests/*/ $repository_path/manifests/.*/; do
88+
[ -d "$dir" ] || continue
89+
[[ "$dir" == */. || "$dir" == */.. ]] && continue
90+
cp -R "$dir" $manifests_path/
91+
done
8292

8393
ln -s $manifests_path /home/ec2-user/environment/eks-workshop
8494
fi

lab/scripts/setup.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,28 @@ EOT
3030

3131
touch ~/.bashrc.d/workshop-env.bash
3232

33+
REPOSITORY_OWNER=${REPOSITORY_OWNER:-"aws-samples"}
34+
REPOSITORY_NAME=${REPOSITORY_NAME:-"eks-workshop-v2"}
35+
REPOSITORY_REF=${REPOSITORY_REF:-"main"}
36+
3337
cat << EOT > /home/ec2-user/.bashrc.d/aliases.bash
3438
function prepare-environment() {
3539
start_time=\$(date +%s)
40+
41+
if [[ "\$1" == fastpaths/* ]]; then
42+
cluster_name="\$EKS_CLUSTER_AUTO_NAME"
43+
create_cmd="create-cluster-auto"
44+
else
45+
cluster_name="\$EKS_CLUSTER_NAME"
46+
create_cmd="create-cluster"
47+
fi
48+
49+
if ! aws eks describe-cluster --name "\$cluster_name" --no-cli-pager &>/dev/null; then
50+
echo "Error: EKS cluster '\$cluster_name' does not exist."
51+
echo "Please create it first by running: \$create_cmd"
52+
return 1
53+
fi
54+
3655
bash /usr/local/bin/reset-environment \$1
3756
exit_code=\$?
3857
source ~/.bashrc.d/workshop-env.bash
@@ -41,13 +60,12 @@ function prepare-environment() {
4160
}
4261
4362
function use-cluster() { bash /usr/local/bin/use-cluster \$1; source ~/.bashrc.d/env.bash; }
44-
function create-cluster() { URL=https://raw.githubusercontent.com/${REPOSITORY_OWNER}/${REPOSITORY_NAME}/refs/heads/${REPOSITORY_REF}/cluster/eksctl/cluster.yaml; echo "Creating cluster with eksctl from $URL"; curl -fsSL $URL | envsubst | eksctl create cluster -f -; }
45-
function create-cluster-auto() { URL=https://raw.githubusercontent.com/${REPOSITORY_OWNER}/${REPOSITORY_NAME}/refs/heads/${REPOSITORY_REF}/cluster/eksctl/cluster-auto.yaml; echo "Creating cluster with eksctl from $URL"; curl -fsSL $URL | envsubst | eksctl create cluster -f -; }
63+
function create-cluster() { URL=https://raw.githubusercontent.com/\${REPOSITORY_OWNER}/\${REPOSITORY_NAME}/refs/heads/\${REPOSITORY_REF}/cluster/eksctl/cluster.yaml; echo "Creating cluster with eksctl from \$URL"; curl -fsSL \$URL | envsubst | eksctl create cluster -f -; }
64+
function create-cluster-auto() { URL=https://raw.githubusercontent.com/\${REPOSITORY_OWNER}/\${REPOSITORY_NAME}/refs/heads/\${REPOSITORY_REF}/cluster/eksctl/cluster-auto.yaml; echo "Creating cluster with eksctl from \$URL"; curl -fsSL \$URL | envsubst | eksctl create cluster -f -; }
65+
function delete-cluster() { URL=https://raw.githubusercontent.com/\${REPOSITORY_OWNER}/\${REPOSITORY_NAME}/refs/heads/\${REPOSITORY_REF}/cluster/eksctl/cluster.yaml; echo "Creating cluster with eksctl from \$URL"; curl -fsSL \$URL | envsubst | eksctl delete cluster -f -; }
66+
function delete-cluster-auto() { URL=https://raw.githubusercontent.com/\${REPOSITORY_OWNER}/\${REPOSITORY_NAME}/refs/heads/\${REPOSITORY_REF}/cluster/eksctl/cluster-auto.yaml; echo "Creating cluster with eksctl from \$URL"; curl -fsSL \$URL | envsubst | eksctl delete cluster -f -; }
4667
EOT
4768

48-
REPOSITORY_OWNER=${REPOSITORY_OWNER:-"aws-samples"}
49-
REPOSITORY_NAME=${REPOSITORY_NAME:-"eks-workshop-v2"}
50-
5169
if [ ! -z "$REPOSITORY_REF" ]; then
5270
cat << EOT > ~/.bashrc.d/repository.bash
5371
export REPOSITORY_OWNER='${REPOSITORY_OWNER}'

website/docs/fastpaths/basics/configuration/configmaps/index.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

website/docs/fastpaths/basics/configuration/configmaps/tests/hook-ready.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

website/docs/fastpaths/basics/configuration/index.md

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)