amplify-cli
amplify-cli copied to clipboard
A Lambda function should be able to invoke itself
Is this feature request related to a new or existing Amplify category?
function
Is this related to another service?
No response
Describe the feature you'd like to request
Currently, when running
amplify update function
it is not possible to give a function permissions to invoke itself. I would like adding permissions for self invocation to be an option. I understand that if Amplify will need to follow a different pattern to avoid circular dependencies.
Describe the solution you'd like
As far as I know, Amplify will have to create a separate self invocation policy that is created after the function, then attach that policy to the execution role.
Describe alternatives you've considered
I can edit the generated cloudformation template to add the proposed solution.
Additional context
No response
Is this something that you'd be interested in working on?
- [ ] 👋 I may be able to implement this feature request
Would this feature include a breaking change?
- [ ] ⚠️ This feature might incur a breaking change
Hey @dan-hook :wave: what is the use case for a Lambda invoking itself?
Hey @dan-hook 👋 what is the use case for a Lambda invoking itself?
A lambda can take a single work item, or a list. The first invocation is given a list of work items, each of which may take longer than 15 minutes. It asynchronously invokes itself on each of the work items.
hey @dan-hook, apologies for the delay in a response. From the use case I understand that the event input for the Lambda function would be a list or a single item. Self invoking a Lambda function may not be cost and time effect for your use case.
To follow best practices I would suggest building the code such that if the input is a list the processing code would be in a loop and check for items. If the event input is a single item the default processing code would be invoked once.
Additionally, I would suggest looking into SQS service as a event as this will allow you to process a batch of messages or message.
Furthermore, if you would like to add permissions to a Lambda function we can do so by adding them in custom-policies.json
file.
Closing the issue due to inactivity. Please feel free in reaching out to us, we would be happy in assisting you.
Can we re-open this? We do not want a lambda function to invoke itself but be able to get the IAM role of itself. In general, why amplify disallows a function to get any permissions about itself?