Skip to content

Instantly share code, notes, and snippets.

View ronan-cunningham's full-sized avatar

Ronan Cunningham ronan-cunningham

  • Belfast, Ireland
View GitHub Profile
@ronan-cunningham
ronan-cunningham / ttl.py
Last active June 18, 2021 21:57
Create a DynamoDb time to live value using a number of days as an input
import time
def get_ttl(days: int) -> int:
seconds_since_epoch=int(str(time.time()).split('.')[0])
seconds_in_n_days=days * 86400
time_to_live=seconds_since_epoch + seconds_in_n_days
return time_to_live
@ronan-cunningham
ronan-cunningham / boto_next_token.py
Last active September 25, 2024 07:12
Using "nextToken" with a boto client
from botocore.config import Config
region='eu-west-1'
config = Config(
region_name = region,
retries = {
'max_attempts': 10,
'mode': 'standard'
}
@ronan-cunningham
ronan-cunningham / boto_who_ami.py
Last active September 25, 2024 08:21
Assume role and check credentials with boto
import boto3
from botocore.exceptions import NoCredentialsError, PartialCredentialsError
from botocore.config import Config
import pprint
config = Config(
region_name = region,
retries = {
'max_attempts': 10,
'mode': 'standard'