https://github.com/arnabd64/python-boto3-snippets
Code snippets for official AWS python SDK
https://github.com/arnabd64/python-boto3-snippets
Last synced: about 1 month ago
JSON representation
Code snippets for official AWS python SDK
- Host: GitHub
- URL: https://github.com/arnabd64/python-boto3-snippets
- Owner: arnabd64
- Created: 2023-07-26T01:05:27.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-26T02:04:54.000Z (almost 3 years ago)
- Last Synced: 2025-03-04T17:50:33.309Z (over 1 year ago)
- Language: Jupyter Notebook
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Code Snippets for `boto3`
`boto3` is the official Python SDK for Amazon Web Services. The `boto3` package provides an interface for using AWS programmetically. To get started with `boto3`, you need to have the following packages installed:
```python
awscli == 1.29
boto3 == 1.28
```
+ `awscli` handles the backend the backend requests and user authentication.
+ `boto3` provides api's to communicate with AWS.
## STEP 1: Setting up User Authentication using `awscli`
Obtain the __AWS Access Key__ and the __Secret Key__ from IAM. You can do it by yourself or ask the Cloud Admin to provide the needed keys. You can refer to this [YouTube video](https://www.youtube.com/watch?v=HuE-QhrmE1c)
Then open your terminal and execute the following command
```bash
$ aws configure
```
`awscli` will ask for __Access Key__ and __Secret Key__, fill iy in and also set the `default output` to `json`.
## STEP 2: Check if `boto3` is working
Copy paste this simple code that creates a __S3 Bucket__ and see if it executes correctly
```python
import boto3
# create a client for S3
s3_client = boto3.client("s3")
# create a bucket
response = s3_client.create_bucket(
Bucket = "my-demo-bucket",
CreateBucketConfiguration = dict(LocationConstraint = "ap-south-1")
)
# display the response
print(response)
```
If the above code comes out as a success then you have correctly configured the SDK.