Explore AWS-CLI on Jupyter Notebook.
Learn to use aws-cli on Jupyter Notebook.
Jupyter Notebook, make collaborations easier, supports multiple languages, is compatible with various tools and applications, and offers open-source and cloud-based programming.
AWS-CLI, Command Line Interface is a unified tool to manage your AWS services, configure, control multiple AWS services and automate them through scripts.
Ever came across the thought of using AWS-CLI on Jupyter-Notebook???
Install Jupyter Notebook:
Download and run the Anaconda Link:https://www.anaconda.com/download
After installation, open anaconda navigator, to launch Jupyter Notebook…
Setting up AWS-CLI on Jupyter Notebook:
Before we dive into using AWS-CLI on Jupyter Notebook, we need to ensure that AWS-CLI is installed on our system.
Download and run the AWS CLI MSI installer for Windows (64-bit): https://awscli.amazonaws.com/AWSCLIV2.msi
also, install using pip, the Python package manager.
The exclamation mark (!) in front of a command in a Jupyter Notebook cell indicates to the notebook kernel that the command should be executed in the underlying operating system’s shell or command line interface, rather than being interpreted as Python code.
As you remember we have installed the aws-cli, it creates aconfig, credentials
files in the users’ profile pathC:\Users\mahesh\.aws\
# config file
[default]
region = <aws_account_region>
# credentials file
[default]
aws_access_key_id = '<aws_access_key_id>'
aws_secret_access_key = '<aws_secret_access_key>'
both of these files have a [default]
account, we can add more accounts.
# credentials file
[default]
aws_access_key_id = '<aws_access_key_id>'
aws_secret_access_key = '<aws_secret_access_key>'
[account101]
aws_access_key_id = '<aws_access_key_id>'
aws_secret_access_key = '<aws_secret_access_key>'
set AWS_PROFILE=default or account101
decides which account these commands should be running…!!
set AWS_PROFILE=default
I am using the default
account. Let’s setup AWS-CLI within our notebook environment. Open command prompt
and run aws configure
C:\Users\mahesh>aws configure
AWS Access Key ID: <Enter AWS access Key ID>
AWS Secret Access Key: <Enter AWS Secret Access Key>
Default refion name: <Enter AWS Account Default Region>
Default output format: <Choose an output format or default is json>
Above values will be updated under the default section of credentials
file
Run the command below to see the Access ID and Access Key details.
!aws sts get-caller-identity
# expected-output-from-jupyter-notebook
{
"UserId": "<user_id>",
"Account": "<account_id>",
"Arn": "arn:aws:iam::<account_id>:user/<iam_user>"
}
Let’s check list of buckets in s3:
😄…..Try Experimenting…..😄