Skip to content

Commit

Permalink
Merge pull request aws-ia#17 from aws-samples/feature/make-shell
Browse files Browse the repository at this point in the history
feature: make shell
  • Loading branch information
niallthomson authored Jun 29, 2022
2 parents 3a449cb + 74b40cb commit 6efaf1f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions environment/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions hack/shell.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6efaf1f

Please sign in to comment.