Last active
April 16, 2020 21:23
-
-
Save jhonata-menezes/1bad154cc609ccce3737d4a187bef1d2 to your computer and use it in GitHub Desktop.
Lista e Remove acl publico de buckets da AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import requests | |
# docs - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.BucketAcl.put | |
def s3_remove_acl_public(bucket_name: str): | |
bucket_acl = s3_acl(bucket_name) | |
bucket_acl.put( | |
ACL='private', | |
) | |
return bucket_acl | |
def s3_acl(bucket_name: str): | |
s3 = boto3.resource('s3') | |
return s3.BucketAcl(bucket_name) | |
def s3_get_acl(bucket_name: str): | |
bucket_acl = s3_acl(bucket_name) | |
return bucket_acl.grants | |
def is_public(bucket_name: str) -> bool: | |
response = requests.get(f'https://${bucket_name}.s3.amazonaws.com/', timeout=10) | |
return response.status_code == 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment