Posts

Showing posts from February, 2018

Synchronize tag values between EC2 instances and EBS volumes

Synchronize tag values between EC2 instances
and EBS volumes for the following tags

Name
Owner
Environment
CostCentre

The code also makes use of existing IAM roles with assume role and MFA tokens

# ------------------------------------------
# synchtags.py
# synchronize tag values between EC2 instances
# and EBS volumes for the following tags
#
#Name
#Owner
#Environment
#CostCentre
#
# ------------------------------------------
import boto3
import sys
from datetime import datetime, timedelta

# Account Switch
print(sys.argv[1])
if sys.argv[1] == "Production":
sRoleSessionName="Production"
sRoleArn="arn:aws:iam::xxxxxxxxxxxx:role/production-fulladmin"
sSerialNumber="arn:aws:iam::xxxxxxxxxxxx:mfa/username"

if sys.argv[1] == "Development":
sRoleSessionName="Development"
sRoleArn="arn:aws:iam::xxxxxxxxxxxx:role/development-fulladmin"
sSerialNumber="arn:aws:iam::xxxxxxxxxxxx:mfa/username"

mfa_token = input("Enter the …

Build and Test Serverless Applications Locally

AWS SAM Local is a CLI tool for local development and testing of Serverless applications