How to use boto3 with Google Colab and AWS integration

Have you ever thought that you want to confirm the operation of codes one by one when implementation of AWS Lambda?

You probably think it is pain to implement on AWS console because you have to run Lambda function and it costs each time.

Therefore, I…


This content originally appeared on DEV Community and was authored by Kyota Nakada

Have you ever thought that you want to confirm the operation of codes one by one when implementation of AWS Lambda?

You probably think it is pain to implement on AWS console because you have to run Lambda function and it costs each time.

Therefore, I will show you the solution of your worry.
It is implementation with Google Colab and AWS integration.

The steps is following:

Step 1: Store AWS configuration files on Google Drive

Operating system Default location and name of files
Linux and macOS ~/.aws/config

~/.aws/credentials
Windows %USERPROFILE%.aws\config

%USERPROFILE%.aws\credentials

Resource
Location of the shared config and credentials files - AWS SDKs and Tools

Step 2: Mount Google Drive

from google.colab import drive
drive.mount('/content/drive')

Step 3: AWS Authetication configuration

import os

config_file = "/content/drive/MyDrive/path/to/file/config"
os.environ['AWS_CONFIG_FILE'] = config_file

credentials_file = "/content/drive/MyDrive/path/to/file/credentials"
os.environ['AWS_SHARED_CREDENTIALS_FILE'] = credentials_file

Step 4: Install boto3

!pip install boto3

Caution
You should configure appropriate IAM Role to >operate AWS resources.
Don't forget it!

In this way, you can implement Lambda function simply and flexibly on Google Colab.

Please try it!


This content originally appeared on DEV Community and was authored by Kyota Nakada


Print Share Comment Cite Upload Translate Updates
APA

Kyota Nakada | Sciencx (2024-08-20T01:39:17+00:00) How to use boto3 with Google Colab and AWS integration. Retrieved from https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/

MLA
" » How to use boto3 with Google Colab and AWS integration." Kyota Nakada | Sciencx - Tuesday August 20, 2024, https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/
HARVARD
Kyota Nakada | Sciencx Tuesday August 20, 2024 » How to use boto3 with Google Colab and AWS integration., viewed ,<https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/>
VANCOUVER
Kyota Nakada | Sciencx - » How to use boto3 with Google Colab and AWS integration. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/
CHICAGO
" » How to use boto3 with Google Colab and AWS integration." Kyota Nakada | Sciencx - Accessed . https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/
IEEE
" » How to use boto3 with Google Colab and AWS integration." Kyota Nakada | Sciencx [Online]. Available: https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/. [Accessed: ]
rf:citation
» How to use boto3 with Google Colab and AWS integration | Kyota Nakada | Sciencx | https://www.scien.cx/2024/08/20/how-to-use-boto3-with-google-colab-and-aws-integration/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.