Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/AWS/AWS_Setup_connection.ipynb
2973 views
Kernel: Python 3

AWS.png

AWS - Setup connection

Give Feedback | Bug report

Tags: #aws #naas #secret #connection #setup

Last update: 2023-11-20 (Created: 2023-11-20)

Description: This notebook help you setup your connection with AWS and add required credentials to Naas secret. You will be able to establish a seamless connection to AWS without the need to repeatedly redefine your credentials in variables by using naas.secret.get() in your notebook.

Input

Import libraries

import naas

Setup variables

Pre-requisites

To get your AWS access key ID, AWS secret access key:

  1. Log in to the AWS Management Console.

  2. Open the IAM (Identity and Access Management) service.

  3. In the left navigation pane, click on "Users".

  4. Select your IAM user from the list or create a new user if needed.

  5. Open the "Security credentials" tab for the selected user.

  6. Under "Access keys", you can view your existing access key or create a new one.

  7. Take note of the Access Key ID and Secret Access Key.

Mandatory

  • aws_access_key_id: AWS access key ID. This value will be stored under the secret 'AWS_ACCESS_KEY_ID'.

  • aws_secret_access_key: AWS secret access key. This value will be stored under the secret 'AWS_SECRET_ACCESS_KEY'.

Optional

  • secrets: Dict to add secrets to naas

# Mandatory aws_access_key_id = None aws_secret_access_key = None # Optional secrets = { "AWS_ACCESS_KEY_ID": aws_access_key_id, "AWS_SECRET_ACCESS_KEY": aws_secret_access_key, }

Model

Add secret

for secret in secrets: new_value = secrets.get(secret) if new_value: naas.secret.add(secret, secrets.get(secret))

Output

Display result

df = naas.secret.list() df = df[df["name"].isin(secrets.keys())] df