Skip to content

Instantly share code, notes, and snippets.

@mhjwork
mhjwork / update-dns.py
Last active June 24, 2017 16:36
Dynamic DNS using AWS
#!/usr/bin/python
# Run this script as a cron job on a machine inside your network that is always on
# Prerequisites:
# - Python
# - boto3 module for AWS access
# - Route 53 DNS hosted zone that you use as the target
# - SNS topic to send notifications when the DNS is updated (IP changed)
#
@mhjwork
mhjwork / assumeRole.rb
Last active August 29, 2015 14:16
Assuming an AWS STS role (with multi-factor authentication) using Ruby
def assumeRole(region: 'eu-west-1', role_arn: nil, session: 'temp', duration: 3600, mfa_arn: nil, token: nil)
# returns a Credentials object for the assumed role, built from:
# region: the AWS region to connect to (default: eu-west-1),
# role_arn: the role ARN that you want to assume,
# session: the name you want to give the session (default: 'temp'),
# duration: seconds the assumed role is valid for (default: 3600),
# mfa_arn: the ARN for the MFA token associated with the user
# token: the 6-digit token ID from the MFA device
#
# This assumes that you have already defined your normal AWS credentials,