diff --git a/Makefile b/Makefile index 0b87392a14..41ce7b1cc9 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,10 @@ test: e2e-test: bash hack/run-e2e.sh +.PHONY: shell +shell: + bash hack/shell.sh + .PHONY: update-helm-versions update-helm-versions: bash hack/update-helm-versions.sh \ No newline at end of file diff --git a/README.md b/README.md index e6a8899162..48eb054ab4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,25 @@ -## Amazon Elastic Kubernetes Service Workshop +# Amazon Elastic Kubernetes Service Workshop ![Tests](https://github.com/aws-samples/eks-workshop-v2/actions/workflows/ci.yaml/badge.svg?branch=main) Welcome to the content repository for the Amazon Elastic Kubernetes Services workshop. +## Navigating the repository + +The top level repository can be split is to several areas. + +### Site content + +The workshop content itself is a `hugo` site within the `site` directory. All workshop content is written using Markdown and can be found in `site/content`. + +### Workshop infrastructure + +The infrastructure required to run the workshop content (EKS cluster configuration, VPC networking, components like Helm charts) are defined as Terraform infrastructure-as-code configuration in the `terraform` directory. + +### Learner environment + +There are several tools that are required to run the workshop such as `kubectl` that need to be installed for a participant to complete the workshop content. This "learner environment" can be setup automatically using the scripts and other artifacts in the `environment` directory. This includes scripts to install all the pre-requisite tools, as well as container images to easily re-create a consistent environment. + ## Security See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. diff --git a/environment/entrypoint.sh b/environment/entrypoint.sh index a1be71a1e9..6c6f040c9f 100644 --- a/environment/entrypoint.sh +++ b/environment/entrypoint.sh @@ -2,8 +2,8 @@ set -e -if [ ! -z "$CLUSTER_NAME" ]; then - aws eks update-kubeconfig --name $CLUSTER_NAME +if [ ! -z "$EKS_CLUSTER_NAME" ]; then + aws eks update-kubeconfig --name $EKS_CLUSTER_NAME fi bash -l \ No newline at end of file diff --git a/hack/shell.sh b/hack/shell.sh new file mode 100644 index 0000000000..aea2b50240 --- /dev/null +++ b/hack/shell.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -Eeuo pipefail + +if [ -z "$ASSUME_ROLE" ]; then + echo "Must set ASSUME_ROLE environment variable" + exit 1 +fi + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +echo "Generating temporary AWS credentials..." + +ACCESS_VARS=$(aws sts assume-role --role-arn $ASSUME_ROLE --role-session-name eks-workshop-shell | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId) AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey) AWS_SESSION_TOKEN=\(.SessionToken)"') + +echo "Building container images..." + +(cd $SCRIPT_DIR/../environment && docker build -q -t eks-workshop-environment .) + +# TODO: Retrieve this from state file +export EKS_CLUSTER_NAME="eksw-env-cluster-eks" + +# TODO: This should probably not use eval +eval "$ACCESS_VARS" + +echo "Starting shell in container..." + +docker run -v $SCRIPT_DIR/../site/content:/content -it \ + -e "EKS_CLUSTER_NAME" -e "AWS_ACCESS_KEY_ID" -e "AWS_SECRET_ACCESS_KEY" -e "AWS_SESSION_TOKEN" -e "AWS_DEFAULT_REGION" \ + eks-workshop-environment \ No newline at end of file