chalice icon indicating copy to clipboard operation
chalice copied to clipboard

Add Alias parameter or some more predictable pattern to function names

Open KeynesYouDigIt opened this issue 5 years ago • 6 comments

I have a pure lambda defined in my app that I would like another function to invoke conditionally

@app.lambda_function(name=NAME)
def some_func(payload_s: str, context: Any)

But when I go to invoke it, of course, I can't reliably find it, because the name has added a bunch of chalice stuff to it app-name-NAME-1C4XDPDWAKN3I

Is there a way I dont know of to make this name easy to find? if not how could I go about aliasing this function? Would that be a new feature?

KeynesYouDigIt avatar Feb 11 '21 16:02 KeynesYouDigIt

FWIW, even using what appears to be the correct function name, my app cannot invoke the pure lambda, its not clear why.

[ERROR] ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the Invoke operation: Function not found: arn:aws:lambda:us-east-1:[account num redacted]:function:app-name-NAME-1C4XDPDWAKN3I ...

KeynesYouDigIt avatar Feb 11 '21 17:02 KeynesYouDigIt

I looked at the exact arn in the error and the exact arn in the function and they are the same... any ideas as to why the app cant find this function?

We would like to do this instead of kicking off work using SQS/Dynamo/something external, but maybe thats the wrong thing to do?

KeynesYouDigIt avatar Feb 11 '21 17:02 KeynesYouDigIt

For those who are having trouble - you can use introspection into your app to find your function. Its a bit of a pain and I would like to see it made easier but this worked

lambda_client = boto3.client('lambda')

lambda_client.invoke(
app._current_app.pure_lambda_functions[0].name

KeynesYouDigIt avatar Feb 11 '21 17:02 KeynesYouDigIt

[ERROR] AttributeError: 'NoneType' object has no attribute 'pure_lambda_functions' Is what I get when this is deployed instead of running locally. Any help? Any ideas?

KeynesYouDigIt avatar Feb 11 '21 18:02 KeynesYouDigIt

I used boto and list functions to write a search utility that goes and gets what I need for now. I might also try to alias this function, not entirely sure of an easy way to do that.

KeynesYouDigIt avatar Feb 11 '21 19:02 KeynesYouDigIt

@KeynesYouDigIt i'm in the same situation, did you ever find a nice way of achieving this?

rmetcalfe-msp avatar Nov 01 '23 17:11 rmetcalfe-msp