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
#!/usr/local/bin/python3 | |
import os | |
import sys | |
import boto3 | |
import time | |
import platform | |
import subprocess | |
from botocore.exceptions import ClientError | |
from queue import Queue | |
from threading import Thread |
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
from botocore.exceptions import ClientError | |
from random import randint | |
from time import sleep | |
import logging | |
import boto3 | |
import json | |
import os | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": "ec2:AssociateAddress", | |
"Resource": "arn:aws:ec2:*:*:instance/*" | |
}, | |
{ |
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
from botocore.exceptions import ClientError | |
from random import randint | |
from time import sleep | |
import logging | |
import boto3 | |
import json | |
import os | |
''' |
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 os | |
import json | |
import boto3 | |
from botocore.exceptions import ClientError | |
from base64 import b64encode | |
def lambda_handler(event, context): | |
# use 'AWS_REGION' environment variable from lambda built-in variables | |
aws_region = os.environ['AWS_REGION'] |
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 os | |
import boto3 | |
import string | |
import random | |
import logging | |
import json | |
from botocore.exceptions import ClientError | |
def hours_to_seconds(hour: int): |
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 | |
def put_lifecycle_policy(region: str, bucket: str, policy): | |
s3 = boto3.client('s3', region_name=region) | |
try: | |
response = s3.put_bucket_lifecycle_configuration(Bucket=bucket, LifecycleConfiguration=policy) | |
except Exception as e: | |
print(str(e)) | |
return response |
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 | |
from datetime import timedelta, datetime | |
### Logic: | |
# this script will list all aws buckets and will retrieve each bucket size per storage type, | |
# output will be displayed in Mb, if the output is 0Mb, the specific storage size is less than 1Mb. | |
# output will only display used storage types | |
# Written by Avi Keinan, 2019. | |
### |
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 os | |
import json | |
import boto3 | |
from botocore.exceptions import ClientError | |
def lambda_handler(event, context): | |
# use 'AWS_REGION' environment variable from lambda built-in variables | |
aws_region = os.environ['AWS_REGION'] | |
bucket_name = os.environ['BUCKET_NAME'] |
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 json | |
import os | |
import sys | |
import boto3 | |
from queue import Queue | |
from threading import Thread | |
from tabulate import tabulate | |
class Aws: |