def update_cfg(args): """Update the configuration (everything but code) of the lambda function. """ if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') kwargs = { 'FunctionName': args.name, 'Runtime': 'python2.7' } if args.role is not None: kwargs['Role'] = args.role if args.handler is not None: kwargs['Handler'] = args.handler if args.desc is not None: kwargs['Description'] = args.desc if args.timeout is not None: kwargs['Timeout'] = args.timeout if args.mem is not None: kwargs['MemorySize'] = args.mem if args.vpcsubnets is not None and args.vpcsecgroups is not None: kwargs['VpcConfig'] = { 'SubnetIds': args.vpcsubnets, 'SecurityGroupIds': args.vpcsecgroups } resp = client.update_function_configuration(**kwargs) print(resp)
def update_cfg(args): """Update the configuration (everything but code) of the lambda function. """ if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') kwargs = {'FunctionName': args.name, 'Runtime': 'python2.7'} if args.role is not None: kwargs['Role'] = args.role if args.handler is not None: kwargs['Handler'] = args.handler if args.desc is not None: kwargs['Description'] = args.desc if args.timeout is not None: kwargs['Timeout'] = args.timeout if args.mem is not None: kwargs['MemorySize'] = args.mem if args.vpcsubnets is not None and args.vpcsecgroups is not None: kwargs['VpcConfig'] = { 'SubnetIds': args.vpcsubnets, 'SecurityGroupIds': args.vpcsecgroups } resp = client.update_function_configuration(**kwargs) print(resp)
def update_code(args): """Point the lambda function at new code. """ if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') resp = client.update_function_code(FunctionName=args.name, S3Bucket=args.bucket, S3Key=args.key) print(resp)
def update_code(args): """Point the lambda function at new code. """ if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') resp = client.update_function_code( FunctionName=args.name, S3Bucket = args.bucket, S3Key = args.key) print(resp)
def create(args): if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') resp = client.create_function( FunctionName=args.name, Runtime='python2.7', Role=args.role, Handler=args.handler, Description=args.desc, Code={'S3Bucket': args.bucket, 'S3Key': args.key}, Timeout=args.timeout, MemorySize=args.mem, VpcConfig={'SubnetIds': args.vpcsubnets, 'SecurityGroupIds': args.vpcsecgroups}) print(resp)
def create(args): if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) client = session.client('lambda') resp = client.create_function(FunctionName=args.name, Runtime='python2.7', Role=args.role, Handler=args.handler, Description=args.desc, Code={ 'S3Bucket': args.bucket, 'S3Key': args.key }, Timeout=args.timeout, MemorySize=args.mem, VpcConfig={ 'SubnetIds': args.vpcsubnets, 'SecurityGroupIds': args.vpcsecgroups }) print(resp)
def setup_parser(): parser = argparse.ArgumentParser( description= 'Script for deleting lambda functions. To supply arguments from a file, provide the filename prepended with an `@`.', fromfile_prefix_chars='@') parser.add_argument( '--aws-credentials', '-a', metavar='<file>', default=os.environ.get('AWS_CREDENTIALS'), type=argparse.FileType('r'), help= 'File with credentials for connecting to AWS (default: AWS_CREDENTIALS)' ) parser.add_argument('name', help='Name of function.') return parser if __name__ == '__main__': parser = setup_parser() args = parser.parse_args() if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) delete_func(session, args.name)
def setup_parser(): parser = argparse.ArgumentParser( description='Script for deleting lambda functions. To supply arguments from a file, provide the filename prepended with an `@`.', fromfile_prefix_chars = '@') parser.add_argument( '--aws-credentials', '-a', metavar = '<file>', default = os.environ.get('AWS_CREDENTIALS'), type = argparse.FileType('r'), help = 'File with credentials for connecting to AWS (default: AWS_CREDENTIALS)') parser.add_argument( 'name', help = 'Name of function.') return parser if __name__ == '__main__': parser = setup_parser() args = parser.parse_args() if args.aws_credentials is None: # This allows aws roles to be used to create sessions. session = boto3.session.Session() else: session = create_session(args.aws_credentials) delete_func(session, args.name)