aws:executeScript – Run a script - AWS Systems Manager

aws:executeScript – Run a script

Runs the Python or PowerShell script provided using the specified runtime and handler. (For PowerShell, the handler isn't required.)

The aws:executeScript action contains the following preinstalled PowerShell Core modules:

  • Microsoft.PowerShell.Host

  • Microsoft.PowerShell.Management

  • Microsoft.PowerShell.Security

  • Microsoft.PowerShell.Utility

  • PackageManagement

  • PowerShellGet

To use PowerShell Core modules that aren't preinstalled, your script must install the module with the -Force flag, as shown in the following command.

Install-Module ModuleName -Force

To use PowerShell Core cmdlets in your script, we recommend using the AWS.Tools modules, as shown in the following commands.


Installing the AWSPowerShell.NetCore module isn't supported.

  • Amazon S3 cmdlets.

    Install-Module AWS.Tools.S3 -Force Get-S3Bucket -BucketName bucketname
  • Amazon EC2 cmdlets.

    Install-Module AWS.Tools.EC2 -Force Get-EC2InstanceStatus -InstanceId instanceId
  • Common, or service independent AWS Tools for Windows PowerShell cmdlets.

    Install-Module AWS.Tools.Common -Force Get-AWSRegion

If your script initializes new objects in addition to using PowerShell Core cmdlets, you must also import the module as shown in the following command.

Install-Module AWS.Tools.EC2 -Force Import-Module AWS.Tools.EC2 $tag = New-Object Amazon.EC2.Model.Tag $tag.Key = "myTag" $tag.Value = "myTagValue" New-EC2Tag -Resource i-12345678 -Tag $tag

For examples of installing and importing AWS.Tools modules, and using PowerShell Core cmdlets in runbooks, see Walkthrough: Using Document Builder to create a custom runbook.


Each aws:executeScript action can run up to a maximum duration of 600 seconds (10 minutes). You can limit the timeout by specifying the timeoutSeconds parameter for an aws:executeScript step.


Provide the runtime and handler required to run the provided Python 3.6, Python 3.7, or PowerShell Core 6.0 script.


The script input parameter isn't supported for JSON runbooks. JSON runbooks must provide script content using the attachment input parameter.

action: "aws:executeScript" inputs: Runtime: "python3.6" Handler: "script_handler" InputPayload: "parameter1": "parameter_value1" "parameter2": "parameter_value2" Script: > def script_handler(events, context): (script commands) Attachment: ""
{ "action": "aws:executeScript", "inputs": { "Runtime": "python3.6", "Handler": "script_handler", "InputPayload": { "parameter1": "parameter_value1", "parameter2": "parameter_value2" }, "Attachment": "" } }

The runtime language to be used for executing the provided script. aws:executeScript supports Python 3.6 (python3.6), Python 3.7 (python3.7), and PowerShell Core 6.0 (dotnetcore2.1) scripts.

Supported values: python3.6 | python3.7 | PowerShell Core 6.0

Type: String

Required: Yes


The entry for running the script, usually a function name. You must ensure the function defined in the handler has two parameters, events and context.


This field is not allowed if the runtime is a PowerShell runtime.

Type: String

Required: Yes (Python) | Not allowed (PowerShell)


A JSON or YAML object that will be passed to the first parameter of the handler. This can be used to pass input data to the script.

Type: String

Required: No


An embedded script that you want to run during the automation. (Not supported for JSON runbooks.)

Type: String

Required: No (Python) | Yes (PowerShell)


The name of a standalone script file or .zip file that can be invoked by the action. To invoke a file for Python, use the filename.method_name format in Handler. For PowerShell, invoke the attachment using and inline script. Gzip isn't supported.

When including Python libraries in your attachment, we recommend adding an empty file in each module directory. This allows you to import the modules from the library in your attachment within your script content. For example: from library import module

Type: String

Required: No



The JSON representation of the object returned by your function. Up to 100KB is returned.