Skip to content
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

Is it possible to pass in a Resource as an input during execution? #340

Closed
SanjayS5 opened this issue May 28, 2020 · 1 comment
Closed

Comments

@SanjayS5
Copy link

SanjayS5 commented May 28, 2020

Question about a possible feature

Description

Is it possible to pass in a Resource as an input during execution?

GetExecutionName:
  Type: Task
  Resource: arn:aws:states:::lambda:invoke
  Parameters:
    FunctionName.$: $$.DynamicFunctionArn <-- Is this possible?
    Payload:
      ExecutionName.$: "$$.Execution.Name"

Example adapted from issue 209 linked below

For example, I want to be able to retry a lambda. Normally, I would have to enter the ARN of the lambda into the resource section like so "Resource: some_lambda_arn".

In my case, I will not know the lamdba ARN in advance. Instead, I will get the lambda ARN as part of the error attributes sent as part of Serverless' error destinations functionality via SQS.

Use case: If Lambda A fails, the failure is sent to SQS -> Lambda B which triggers a state machine to retry Lambda A

(Note: The ARN of lambda A is sent as an attribute of the failure message to SQS).

My questions i, can I pass in the ARN of Lambda A as an input to the state machine, which then uses that to set the Resource?

EDIT: Just stumbled across this issues/209 But instead of the hardcoded ARN, I want to pass in the ARN as an input variable.

@SanjayS5
Copy link
Author

As it turns out, you can!

GetExecutionName:
  Type: Task
  Resource: arn:aws:states:::lambda:invoke
  Parameters:
    FunctionName.$: $.DynamicFunctionArn

This is what you would do, and the reason it wasn't working for me is because I had an extra hyphen before FunctionName :)

Can I please request that this feature be added to the documentation? Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant