Setting up a working environment for Amazon EKS with AWS CloudShell

Search for a command to run...

No comments yet. Be the first to comment.
π‘ The tools discussed in this article leverage the AWS Health API, which requires a Business or higher-level AWS Support plan. Introduction For all AWS Organizations administrators worldwide, how do you handle the events notified by AWS Health? I ...
Introduction I have created a sample chatbot application that uses Chainlit and LangChain to showcase Amazon Bedrock. You can interact with the AI assistant while switching between multiple models. This sample application has been tested in the foll...
Introduction Here is a simple example of running Mountpoint for Amazon S3 from inside a container Created with information as of 3/21/2023 (version: 0.2.0-b8363a4) Mountpoint for Amazon S3 is currently in alpha release and should not be used in pro...
Introduction GitHub Enterprise Cloud audit logs support log streaming to various cloud providers. https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/streaming-the-a...
Why do we need automation? Member accounts added to AWS Organizations after subscribing to Enterprise Support are not enrolled in Enterprise Support. To register a new member account with Enterprise Support, you must open a support case in the manage...
AWS Cloud Shell was announced at the Werner Vogels Keynote at AWS re:Invent 2020.
π AWS CloudShell β Command-Line Access to AWS Resources https://aws.amazon.com/jp/blogs/aws/aws-cloudshell-command-line-access-to-aws-resources/
AWS CloudShell is a browser-based shell that can be launched directly from the AWS management console.
The shell can use Bash, PowerShell, Z shell, and comes preconfigured with tools to support the AWS CLI and other major development languages.
The pre-setup tools are described in the following document.
AWS CloudShell compute environment: specifications and software https://docs.aws.amazon.com/cloudshell/latest/userguide/vm-specs.html
For example, kubectl is not installed.
Let's prepare the working environment for Amazon EKS by yourself.
Is the installation of additional software in a shell environment supported?
Yes, but it must be managed by the user. (Shared Responsibility modelπ)
Just click on the icon on the managed console to launch CloudShell.

The installation directory is set to $HOME/.local/bin
This is because the persistent storage that is maintained between sessions is $HOME. (See the second half of this article for details.)
# Create directory
mkdir -p $HOME/.local/bin
cd $HOME/.local/bin
# kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.13/bin/linux/amd64/kubectl
chmod +x kubectl
# Create $HOME/.kube/config
aws eks update-kubeconfig --name <YOUR_CLUSTER_NAME>
# eksctl
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl $HOME/.local/bin
# helm
export VERIFY_CHECKSUM=false
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
sudo mv /usr/local/bin/helm $HOME/.local/bin
Packages installed by yum cannot be placed in persistent storage ($HOME), so they need to be installed for each new session.
You can write a command in your .bash_profile to automatically install them when you start CloudShell.
I want to use kubectl completion, so I installed bash-completion.
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
# Install at startup
sudo yum install -y bash-completion > /dev/null 2>&1
The kubectl completion configuration can be saved to persistent storage.
kubectl completion bash > $HOME/.bash_completion
As with any service, you need to explicitly grant CloudShell access to the target IAM user/role.
It is easiest to use the AWSCloudShellFullAccess AWS managed policy, but if you want to restrict file upload/download via CloudShell, you can use a custom policy like the following.
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "CloudShellUser",
"Effect": "Allow",
"Action": [
"cloudshell:*"
],
"Resource": "*"
}, {
"Sid": "DenyUploadDownload",
"Effect": "Deny",
"Action": [
"cloudshell:GetFileDownloadUrls",
"cloudshell:GetFileUploadUrls"
],
"Resource": "*"
}]
}
Automatically uses the IAM credentials you used to sign in to the AWS Management Console.
This means that the operating IAM user/role must have explicit permission to access the target AWS service.
AWS CloudShell - User Guide
https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html