AWS
AWS Essentials
- AWS CLI
- IAM Access Management
- S3 Bucket
- Secret Manager
S3 Bucket
Getting started with S3 command-line
Create a bucket named de-first
aws s3api create-bucket --bucket de-first
List all the buckets
aws s3 ls
List the content of a bucket named de-first
aws s3 ls s3://de-first/
Copy a local file /Files/sample.txt
to the bucket de-first
aws s3 cp /Files/sample.txt s3://de-first/sample.txt
Sync all files of a folder /Files
to the bucket's datafiles
folder
aws s3 sync /Files s3://de-first/datafiles
Boto3
Download an object from a S3 bucket to a local file using the Resource API (high-level) of Boto 3:
awss3download-rapi/s3download.py
loading...
Secret Manager
Retrieve the value of a secret
import boto3
import json
def get_secret(secret_name, region_name="us-east-1"):
session = boto3.session.Session()
client = session.client(
service_name='secretsmanager',
region_name=region_name)
get_secret_value_response = client.get_secret_value(SecretId=secret_name)
get_secret_value_response = json.loads(get_secret_value_response['SecretString'])
return get_secret_value_response
secret_values = get_secret(secret_name='de')