Skip to content

Commit

Permalink
Allow lazy function invocation to target version/alias (#679)
Browse files Browse the repository at this point in the history
* Allow lazy function invocation to target version/alias
* Updating test to properly mock function ARN
  • Loading branch information
angrychimp authored Jul 12, 2022
1 parent 208992c commit 421c0d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions slack_bolt/adapter/aws_lambda/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def handle(self, event, context):
# https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
aws_lambda_function_name = context.function_name
bolt_req.context["aws_lambda_function_name"] = aws_lambda_function_name
bolt_req.context["aws_lambda_invoked_function_arn"] = context.invoked_function_arn
bolt_req.context["lambda_request"] = event
bolt_resp = self.app.dispatch(bolt_req)
aws_response = to_aws_response(bolt_resp)
Expand Down
2 changes: 1 addition & 1 deletion slack_bolt/adapter/aws_lambda/lazy_listener_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def start(self, function: Callable[..., None], request: BoltRequest) -> None:
headers["x-slack-bolt-lazy-function-name"] = request.lazy_function_name # not an array
event["method"] = "NONE"
invocation = self.lambda_client.invoke(
FunctionName=request.context["aws_lambda_function_name"],
FunctionName=request.context["aws_lambda_invoked_function_arn"],
InvocationType="Event",
Payload=json.dumps(event),
)
Expand Down
1 change: 1 addition & 0 deletions tests/adapter_tests/aws/test_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LambdaContext:

def __init__(self, function_name: str):
self.function_name = function_name
self.invoked_function_arn = f'arn:aws:lambda:us-east-1:account-id:function:{self.function_name}'


class TestAWSLambda:
Expand Down

0 comments on commit 421c0d0

Please sign in to comment.