Skip to content

Why Does AWS Recommend aws:executeScript Over aws:invokeLambdaFunction for Runbooks When Invoke is Faster?

0

Hello,

I’ve been working on an AWS Systems Manager runbook and noticed that the AWS Document Designer recommends using aws:executeScript for script execution. I have written the same runbook using both aws:executeScript and aws:invokeLambdaFunction, and while both run successfully, I’ve observed significant performance differences.

  • aws:invokeLambdaFunction takes around 2 seconds to execute.
  • aws:executeScript takes approximately 40 seconds for the same task.

I also found it much easier to debug when using aws:invokeLambdaFunction.

I’m trying to understand why aws:executeScript is recommended in the documentation, given the noticeable difference in execution time.

Is there a specific advantage to using aws:executeScript that justifies the longer execution time? For example, does it provide benefits in terms of security, auditing, or automation that aws:invokeLambdaFunction doesn't offer?

Any insights into why AWS recommends aws:executeScript despite the slower performance would be greatly appreciated.

Thanks in advance for your help!

1 Answer
1

Choosing between the ExecuteScript and InvokeLambdaFunction actions in AWS Systems Manager Automation depends heavily on your specific requirements. Each approach has its strengths, and the best choice varies based on the task at hand.

Refer to these two links :

https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-action-lamb.html

https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-action-executeScript.html

ExecuteScript shines when:

  1. Complex logic and customization: If your automation workflow requires running detailed, custom logic or performing operations that require fine control over data or AWS APIs, ExecuteScript is an excellent option. You can write Python scripts tailored to your needs directly within the automation, making it ideal for handling complex processes.
  2. Inline script execution: ExecuteScript enables you to execute Python code inline without relying on external services like Lambda. This makes it convenient for scenarios where you want to reduce dependencies and manage the entire automation flow within Systems Manager.
  3. Minimal external overhead: If you prefer not to manage or deploy separate Lambda functions, and are comfortable with the Python environment provided by AWS Systems Manager, ExecuteScript is a straightforward solution.

InvokeLambdaFunction stands out when:

  1. Reusing existing Lambda functions: If you already have Lambda functions set up for different tasks, this action simplifies integration by invoking those functions. This allows you to leverage your existing serverless infrastructure without the need to write new scripts within the automation.
  2. Serverless scalability: Lambda provides a fully managed, scalable environment, which is ideal for workloads that benefit from its serverless nature. This can be advantageous if your automation needs to handle large, distributed tasks or high volumes of data in a lightweight and scalable way.
  3. Multi-language support: While ExecuteScript is limited to Python, Lambda supports multiple programming languages such as Node.js, Java, and Go. If your automation requires a language other than Python, InvokeLambdaFunction gives you the flexibility to use Lambda functions built in the language that suits your task best.

Conclusion:

  • Use ExecuteScript when you need full control over your automation logic, prefer working within an inline Python environment, and want to keep your dependencies minimal.
  • Use InvokeLambdaFunction when you have reusable Lambda functions that can be invoked across workflows, need the scalability of serverless architecture, or require multi-language support.

In summary, there is no clear "winner" between the two—each action excels in different contexts. The decision should be guided by the complexity of the task, the available resources (like pre-existing Lambda functions), and the specific needs of your automation workflow.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.