Skip to content

Instantly share code, notes, and snippets.

@vkhatri
Last active February 8, 2018 21:08
Show Gist options
  • Save vkhatri/fd3a62025e3555532c86514ada03ec30 to your computer and use it in GitHub Desktop.
Save vkhatri/fd3a62025e3555532c86514ada03ec30 to your computer and use it in GitHub Desktop.
Python Wrapper to Execute Transit VPC Poller Module for Testing
# Module Source - https://github.com/vkhatri/aws-transit-vpc/tree/feature-vrf
# Change Module Source accordingly, currently
import os
import ast
import logging
import sys
# symlink transit-vpc-poller.py module for import workaround
# ln -s transit-vpc-poller.py transit_vpc_poller.py
import transit_vpc_poller
# Set Logging stream to STDOUT
logging.basicConfig(stream=sys.stdout)
# Set S3 Bucket Name
transit_vpc_poller.bucket_name = ''
# Set S3 Bucket Prefix
transit_vpc_poller.bucket_prefix = 'vpnconfigs/'
# Set Config file ext to prevent Lambda Trigger
transit_vpc_poller.config_file_ext = 'conft'
# Set AWS Account Id
account_id = 000000000000
# Event Object
event = {}
# Read Local Configuration File instead of S3 transit_vpc_config.txt
# Comment if want to read config from S3 transit_vpc_config.txt file
# transit_vpc_config_file = 'local_config.txt'
# transit_vpc_config = ast.literal_eval(open(transit_vpc_config_file).read())
# UnComment if want to read config from S3 transit_vpc_config.txt file
transit_vpc_config = None
# Initialize Minimal Context Object
class LambdaContext():
pass
context = LambdaContext()
context.invoked_function_arn = 'arn:aws:lambda:us-east-1:{}:function:transitvpc-vgw-poller'.format(account_id)
# Call Lambda Handler
transit_vpc_poller.lambda_handler(event, context, transit_vpc_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment