Skip to content

Commit 496aa01

Browse files
committed
Ability to specify event file. Closes #1
1 parent 5097be5 commit 496aa01

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

aws_lambda/aws_lambda.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@ def deploy(src):
5050
create_function(cfg, path_to_zip_file)
5151

5252

53-
def invoke(src):
53+
def invoke(src, alt_event=None):
5454
"""Simulates a call to your function.
5555
5656
:param str src:
5757
The path to your Lambda ready project (folder must contain a valid
5858
config.yaml and handler module (e.g.: service.py).
59+
:param str alt_event:
60+
An optional argument to override which event file to use.
5961
"""
6062
# Load and parse the config file.
6163
path_to_config_file = os.path.join(src, 'config.yaml')
6264
cfg = read(path_to_config_file, loader=yaml.load)
6365

6466
# Load and parse event file.
65-
path_to_event_file = os.path.join(src, 'event.json')
67+
if alt_event:
68+
path_to_event_file = os.path.join(src, alt_event)
69+
else:
70+
path_to_event_file = os.path.join(src, 'event.json')
6671
event = read(path_to_event_file, loader=json.loads)
6772

6873
handler = cfg.get('handler')

scripts/lambda

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def init():
2121

2222

2323
@click.command(help="Run a local test of your function.")
24-
def invoke():
25-
aws_lambda.invoke(CURRENT_DIR)
24+
@click.option('--event', default=None, help='Alternate event file.')
25+
def invoke(event_file):
26+
aws_lambda.invoke(CURRENT_DIR, event_file)
2627

2728

2829
@click.command(help="Register and deploy your code to lambda.")

0 commit comments

Comments
 (0)