How to use Lens IDE with two different AWS profiles
What is Lens IDE?
The Lens IDE is a desktop application with a user-friendly interface for managing and interacting with Kubernetes clusters. It offers a centralized dashboard to view and manage multiple clusters, provides real-time metrics and logs, allows for easy deployment and management of applications, and offers various other features to simplify working with Kubernetes.
The Problem
If there is only 1 profile in the AWS CLI, Lens IDE will not give you a problem, but when you start working with more than one profile, you begin to encounter problems.
Editing the active profile manually or rotating the access keys will start to tire you after a while.
I can offer you a solution to overcome this problem. Let's start.
Requirements
Installation
Before starting the installation, let's ensure everything works with a single profile. To achieve this, let's complete the AWS CLI, then kubectl and finally Lens IDE installations.
After the initial single profile setup, you need to create AWS Profile with the following command:
aws configure --profile PROFILE_NAME
Example AWS CLI Config File:
[profile DEMO_1]
region = eu-central-1
output = json
[profile DEMO_2]
region = eu-central-1
output = json
Example AWS CLI Credential File:
[DEMO_1]
aws_access_key_id = XYZ
aws_secret_access_key = 123
[DEMO_2]
aws_access_key_id = ABC
aws_secret_access_key = 321
Install AWSP:
npm install -g awsp
Add the following to your .bashrc
or .zshrc
config
alias awsp="source _awsp"
Now you have installed awsp, if you execute awsp
command in your terminal you can switch in your AWS Profiles.
One more step to achieve the goal. We need to add some environment variables to the kubectl config file.
Open the file and add the following environments for every profile.
users:
- name: [email protected]
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- token
- -i
- dec14
command: aws
env:
- name: AWS_PROFILE
value: DEMO_1
Conclusion
In this article, we learned how to create & manage multiple aws profiles and how to use these profiles with Lens IDE. I hope it was useful.
See you in the next article. 👻