-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various local dev improvements (#973)
- Loading branch information
1 parent
e706119
commit 0188a10
Showing
15 changed files
with
111 additions
and
165 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
#!/bin/bash | ||
|
||
environment=$1 | ||
shift 1 | ||
shell_command=$@ | ||
|
||
set -Eeuo pipefail | ||
|
||
# You can run script with finch like CONTAINER_CLI=finch ./shell.sh <terraform_context> <shell_command> | ||
CONTAINER_CLI=${CONTAINER_CLI:-docker} | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source $SCRIPT_DIR/lib/common-env.sh | ||
|
||
echo "Building container images..." | ||
|
||
container_image='eks-workshop-environment' | ||
|
||
(cd $SCRIPT_DIR/../lab && $CONTAINER_CLI build -q -t $container_image .) | ||
|
||
source $SCRIPT_DIR/lib/generate-aws-creds.sh | ||
|
||
echo "Executing command in container..." | ||
|
||
$CONTAINER_CLI run --rm \ | ||
-v $SCRIPT_DIR/../manifests:/manifests \ | ||
-v $SCRIPT_DIR/../cluster:/cluster \ | ||
--entrypoint /bin/bash \ | ||
-e 'EKS_CLUSTER_NAME' -e 'AWS_REGION' \ | ||
$aws_credential_args $container_image -c "$shell_command" |
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,6 +1,21 @@ | ||
echo "Generating temporary AWS credentials..." | ||
aws_credential_args="" | ||
|
||
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)"') | ||
ASSUME_ROLE=${ASSUME_ROLE:-""} | ||
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-""} | ||
|
||
# TODO: This should probably not use eval | ||
eval "$ACCESS_VARS" | ||
if [ ! -z "$AWS_ACCESS_KEY_ID" ]; then | ||
echo "Using environment AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY" | ||
|
||
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..." | ||
|
||
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)"') | ||
|
||
# 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 |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -12,5 +12,6 @@ if [ $# -eq 0 ] | |
then | ||
bash -l | ||
else | ||
source /home/ec2-user/.bashrc.d/env.bash | ||
bash -c "$@" | ||
fi |
Oops, something went wrong.