Säkra objekt

Introduktion till AWS Boto i Python

Maksim Pecherskiy

Data engineer

Varför bry sig om behörigheter?

df = pd.read_csv('https://gid-staging.potholes.csv')

Behörighetsöversikt

Introduktion till AWS Boto i Python

Varför bry sig om behörigheter?

Behörighet beviljad!

# Generate the boto3 client for interacting with S3
s3 = boto3.client('s3', region_name='us-east-1', 
                         aws_access_key_id=AWS_KEY_ID, 
                         aws_secret_access_key=AWS_SECRET)

# Use client to download a file s3.download_file( Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')
Introduktion till AWS Boto i Python

AWS behörighetssystem

IAM

Bucket Policy

ACL

Presigned URL

Introduktion till AWS Boto i Python

AWS behörighetssystem

IAM

Bucket Policy

ACL

Presigned URL

Introduktion till AWS Boto i Python

ACL:er

ACL

Introduktion till AWS Boto i Python

ACL:er

Ladda upp fil

s3.upload_file(
  Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')

Sätt ACL till 'public-read'

s3.put_object_acl(
  Bucket='gid-requests', Key='potholes.csv', ACL='public-read')
Introduktion till AWS Boto i Python

Sätt ACL vid uppladdning

Ladda upp fil med 'public-read' ACL

s3.upload_file(
  Bucket='gid-requests', 
  Filename='potholes.csv', 
  Key='potholes.csv', 
  ExtraArgs={'ACL':'public-read'})
Introduktion till AWS Boto i Python

Åtkomst till publika objekt

URL-mall för S3-objekt

https://{bucket}.{key}

URL för Key='2019/potholes.csv'

https://gid-requests.2019/potholes.csv
Introduktion till AWS Boto i Python

Generera publik objekt-URL

Generera objektets URL-sträng

url = "https://{}.{}".format(
  "gid-requests", 
  "2019/potholes.csv")

'https://gid-requests.2019/potholes.csv'

# Read the URL into Pandas
df = pd.read_csv(url)
Introduktion till AWS Boto i Python

Hur åtkomst avgörs

Åtkomsthierarki

Introduktion till AWS Boto i Python

Hur åtkomst avgörs

Åtkomsthierarki

Introduktion till AWS Boto i Python

Repetition

IAM

Bucket Policy

ACL

Presigned URL

Introduktion till AWS Boto i Python

Repetition

Sätt ACL till 'public-read'

s3.put_object_acl(
  Bucket='gid-requests', Key='potholes.csv', ACL='public-read')

Sätt ACL till 'private'

s3.put_object_acl(
  Bucket='gid-requests', Key='potholes.csv', ACL='private')
Introduktion till AWS Boto i Python

Repetition

Ladda upp fil med 'public-read' ACL

s3.upload_file(
  Bucket='gid-requests', 
  Filename='potholes.csv', 
  Key='potholes2.csv', 
  ExtraArgs={'ACL':'public-read'})
Introduktion till AWS Boto i Python

Repetition

Generera objektets URL-sträng

url = "https://{}.{}".format(
  "gid-requests", 
  "2019/potholes.csv")

'https://gid-requests.2019/potholes.csv'

# Read the URL into Pandas
df = pd.read_csv(url)
Introduktion till AWS Boto i Python

Nu kör vi en övning!

Introduktion till AWS Boto i Python

Preparing Video For Download...