-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Chalice invoke command #900
Comments
In general, I like the idea but there's a few edge cases I'm curious about:
I'm also not sure if we want this as a top level command. Thinking through the direction of improved local testing, it seems like putting this under the |
Just replying back. Let me know what you think:
It would just accept the raw payload no matter what it is decorated with. So you would have to format the proper event payload if it is hooked up to an event source (i.e. s3 event, sns message, etc.). I think it would be interesting though if we can find a way to do preformatted payload as I mentioned in the initial overview. I'm just not sure how it would look, but I think no matter what it would be great to have the raw payload invoke.
Actually it is not from the SDK. Using the CLI on this from chalice import Chalice
app = Chalice(app_name='hello-lambda')
app.debug = True
@app.lambda_function()
def index(event, context):
print(event)
return {'hello': 'world'} I can run this command:
and it works fine without a payload. If omitted, an empty dictionary is provided.
Yeah I would be fine with it being a positional argument as well. As to a file, I think that is nice especially if we are going to be allowing you to pass raw payloads for non-
Makes sense to me.
I think that could make sense if we were just targeting it for local development. However, the primary way I am planning to use it is to invoke the remote lambda function. You can see an example in one of the PR's I was working on for the new chalice tutorial: aws-samples/chalice-workshop#13. So my main concern is that it would be weird to have that under the |
|
Keeping it as
Not necessarily. We could support reading from stdin, which would actually accommodate both use cases. It's also what other tools such as |
I could see it being part of the HTTP
You could call the
S3
You could call the
Using stdin would suit my use case. I am assuming if stdin is specified it would take no positional arguments and read from stdin like this?
I think that would work fine I would like your thoughts on both of these. |
InputFor the input source I like:
I don't think the
OutputSomething else to consider is the output. We get back the actual response from lambda, one component of which is a payload streaming body. My thought is we just ignore all the metadata and response keys and write the
I'd like to print this information like a standard python error/traceback to stder. I think that would make for the cleanest experience debugging a misbehaving lambda function. |
I'm not really sure what that means. You have a file and an event type? I'm with @stealthycoin on this, I think just keep it simple. If you pipe something to stdin, that's the payload, othewise there's no payload sent. Nothing else for payloads (for now). I think there's enough to go ahead and send a PR. I think we can work out the remaining details on the PR. |
Ok cool. I was just trying to brainstorm on how we could expand on it to handle different invocation types and if we would want to expand on it. Was not trying to suggest that we do it. I like the interface that we have now (after what @stealthycoin suggested). |
I have a POC already so I will update it to match the proposed interface and send a PR. |
Current discussion: aws#900
Current discussion: aws#900
What should we do about the return codes. There are multiple ways it can fail.
|
As to return code, how about the following?
@jamesls @stealthycoin I think it is useful to be able to differentiate between an error being encountered in the lambda function and not being invoked/botocore error |
I would check to be consistent with the other commands. We should use the same RC when we provide a function name that doesn't exist. Assuming that matches the above, it looks good to me. |
For consistency with the other commands I went with:
|
Merged in #901 |
Overview
With all of the new event types being released into Chalice, it would be great if Chalice had a built-in way to invoke the deployed Lambda function (and possibly a local version). Right now, I am invoking these functions through the console or the AWS CLI, but it would be much more convenient if Chalice had a built-in
invoke
command that accepts:--name <function-name>
: The logical name of the Lambda function in the chalice app--stage <stage-name>
: To specify the stage you want to target--payload <value>
: A JSON payload to use when invoking the Lambda functionIt would then print the result of the invoke to standard output.
Example
Using this deployed
app.py
:Users would then be able to invoke the deployed Lambda functions manually:
Future additions
Preformatted event payloads. Not sure how this would look quite yet, but essentially you can just provide the only the important event parameters to
chalice invoke
(i.e. bucket/key for S3 event or message for SNS event) and chalice will take the parameters and format an event on your behalf based on what the event source is and invoke the function.Local mode. Potentially add a
--local
flag so this will invoke your Lambda function in your Chalice application locally.--context <context-value>
. Add the ability to send a context as well as a payload to invoke the Lambda function.The text was updated successfully, but these errors were encountered: