This file contains 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/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) | |
# |
This file contains 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
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, |