Actions Reference for Automation Documents
Systems Manager Automation performs tasks defined in Automation documents. To define a task, you specify one or more of the following actions in any order in the MainSteps section of your Automation document.
aws:runInstance: Launches one or more instances for a given AMI ID.
aws:runCommand: Remote command execution. Executes an SSM Run Command document.
aws:invokeLambdaFunction: Enables you to run external worker functions in your automation workflow.
aws:changeInstanceState: Changes an instance state to stopped, terminated, or running.
aws:createImage: Creates an AMI from a running instance.
aws:deleteImage: Deletes an AMI.
All actions use the syntax shown later in this section. The properties specified outside the inputs section remain the same across all actions. You can use different values for any property in any action.
Common Properties In All Actions
name
A string specifying a unique identifier. The value of this property is expected to be unique across all step names in the document.
Required: Yes
actionA string specifying the name of the action a particular step intends to execute.
Required: Yes
maxAttemptsAn integer value for number of times the step should be retried in case of failures. If the value specified is greater than one, the step is not declared failed until all attempts have failed. One is assumed as the default value.
Required: No
timeoutSecondsAn integer value for the step to timeout the execution.
Required: No
onFailureA string indicating if the workflow should Abort or Continue on failures. By default the value Abort is assumed.
Required: No
inputsMap of properties specific to the action
Required: Yes
Important
The outputs of an action are not supposed to be specified in the document. They are available to the user for linking the steps or adding into the output section of the doc. E.g. if you want to make output of aws:runInstances step, i.e. the instanceId an input for the next action which is let’s say aws:runCommand, you have it available to you. See the example below to understand more.
Syntax
"mainSteps": [
{
"name": "launchInstance",
"action": "aws:runInstances",
"maxAttempts": 3,
"timeoutSeconds": 1200,
"onFailure": "Abort",
"inputs": {
"ImageId": "ami-123456",
"InstanceType": "t2.micro"
}
},
{
"name": "updateInstance",
"action": "aws:runCommand",
"timeoutSeconds": 1200,
"onFailure": "Continue",
"inputs": {
"DocumentName": "AWS-RunShellScript",
"InstanceIds": [
"{{launchInstance.InstanceIds}}"
],
"Parameters": {
"commands": [
"ls -l"
]
}
}
}
]
Action aws:runInstance
You can use this action to launch anew instance. The action supports most run-instance API arguments.
JSON Sample
{
"name": "launchInstance",
"action": "aws:runInstances",
"maxAttempts": 3,
"timeoutSeconds": 1200,
"onFailure": "Abort",
"inputs": {
"ImageId": "ami-123456",
"InstanceType": "t2.micro",
"MinInstanceCount": 1,
"MaxInstanceCount": 1,
"IamInstanceProfileName": "MyRunCmdRole"
}
}
Inputs
The action supports most run-instances API’s parameters. For specific permitted value, please refer to the run-instances api documentation.
ImageIdA string literal containing the id of the image to launch the instance.
Required: Yes
AdditionalInfoA string containing additional info to launch the instance.
Required: No
BlockDeviceMappingsA map list containing the mappings for the instance.
Required: No
ClientTokenA string literal.
Required: No
DisableApiTerminationA boolean value.
Required: No
EbsOptimizedA boolean value.
Required: No
IamInstanceProfileArnA string literal containing the ARN of.
Required: No
IamInstanceProfileNameA string literal containing name of the IAM profile to associate with the instance.
Required: No
InstanceInitiatedShutdownBehaviorA string value.
Required: No
InstanceTypeA string literal containing the instance type.
Required: No
KernelIdA string value containing kernel id.
Required: No
KeyNameA string literal containing the name of the security key.
Required: No
MaxInstanceCountAn integer value for defining the maximum number of instances to be launched.
Required: No
MinInstanceCountAn integer value for defining the minimum number of instances to be launched.
Required: No
MonitoringA boolean value to indicate enabling cloud watch monitoring.
Required: No
NetworkInterfacesA list of maps containing all the network interfaces.
Required: No
PlacementA map of string literals.
Required: No
PrivateIpAddressA string value containing the IP address.
Required: No
RamdiskIdA string literal containing ram disk id.
Required: No
SecurityGroupIdsA list of string literals containing the Ids of the security groups.
Required: No
SecurityGroupsA list of string literals containing the names of the security groups.
Required: No
SubnetIdA string value containing the subnet id.
Required: No
UserDataAn execution script provided as a string literal value.
Required: No
Outputs
InstanceIdsList of string literals containing instance ids.
Action aws:runCommand
You can use this action to run any commands using send-command API. This action supports most send-command API arguments. The example below shows using only one to many public run command documents.
JSON Sample
{
"name": "installPowerShellModule",
"action": "aws:runCommand",
"inputs": {
"DocumentName": "AWS-InstallPowerShellModule",
"InstanceIds": ["i-123456789"],
"Parameters": {
"source": "https://my-s3-url.com/MyModule.zip ",
"sourceHash": "ASDFWER12321WRW"
}
}
}
Inputs
All the inputs listed here are simply the enumeration of all send-command parameters across all public documents. For specific public command document specific value, please refer to the send-command api documentation.
DocumentNameA string literal containing the name of the run command document.
Required: Yes
InstanceIdsA list of string literals containing the ids of the instances.
Required: Yes
ParametersThis is not a property. This is an additional section inside inputs section. It is a map of properties below.
Required: No
CommentA string literal.
Required: No
DocumentHashA string containing hash for the PowerShell module to be installed.
Required: No
DocumentHashTypeA string containing type of the hash. Permitted values are Sha256 and Sha1.
Required: No
NotificationConfigA map of string literals.
Required: No
OutputS3BucketNameA string literal.
Required: No
OutputS3KeyPrefixA string literal.
Required: No
ServiceRoleArnA string literal containing the ARN.
Required: No
TimeoutSecondsAn integer value to specify the run-command timeout seconds.
Required: No
Outputs
CommandIdString literal containing command id.
OutputString literal containing the truncated output of the command.
ResponseCodeString literals containing command status code.
StatusString literal indicating the status of the command.
Action aws:invokeLambdaFunction
You can use this action to invoke an existing Lambda function. Note that this action does not create the function if it does not exist.
JSON Sample
{
"name": "invokeMyLambdaFunction",
"action": "aws:invokeLambdaFunction",
"maxAttempts": 3,
"timeoutSeconds": 120,
"onFailure": "Abort",
"inputs": {
"FunctionName": "MyLambdaFunction"
}
}
Inputs
The action supports most invoke API’s parameters for Lambda service. For specific permitted value, please refer to the invoke api documentation.
FunctionNameA string literal containing the id of the image to launch the instance.
Required: Yes
ClientContextA string containing client context info.
Required: No
InvocationType A string literal with permitted values RequestResponse or Event or DryRun.
Required: No
LogTypeA string literal with permitted values None or Tail.
Required: No
PayloadA string literal.
Required: No
QualifierA string literal.
Required: No
Outputs
StatusCodeA string literals containing the function execution status code.
Action aws:changeInstanceState
You can use this action to either change or assert the state of the instance.
Important
This action can be used in assert mode i.e. not execute the start-instance/stop-instances/terminate-instances API to achieve the desired state, instead just validate that instance is desired state. The assert mode is activated by supplying parameter CheckStateOnly as true. This mode is very useful for customers executing Sysprep command in Windows AMIs. Sysprep is an asynchronous command. It runs in the background and can run for long time. So while its execution is incomplete if aws:changeInstanceState is executed without this flag CheckStateOnly set to true, when instance is stopped it will be in undesired state. The AMIs created from such instances may be defective.
JSON Sample
{
"name":"stopMyInstance",
"action": "aws:changeInstanceState",
"maxAttempts": 3,
"timeoutSeconds": 3600,
"onFailure": "Abort",
"inputs": {
"InstanceIds": ["i-123456789"],
"CheckStateOnly": true,
"DesiredState": "stopped"
}
}
Inputs
DesiredStateA string literal with permitted values running or stopped or terminated.
Required: Yes
InstanceIdsA list of string literals containing the ids of the instances.
Required: Yes
AdditionalInfo A string literal.
Required: No
CheckStateOnlyThis is a boolean literal. If value is false, it’ll execute EC2 API like start-instance/stop-instances/terminate-instances to cause the desired state transition. If true, it only will assert desired state by polling for it.
Required: No
ForceA Boolean value. If set Forces the instances to stop. The instances do not have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances.
Required: No
Outputs
None.
Action aws:createImage
You can use this action to create a new image from a stopped instance.
Important
This action does not stop the instance implicitly. The user needs to use aws:changeInstanceState action to stop the instance. If this action is used on a running instance, the resultant AMI may be defective.
JSON Sample
{
"name":"createMyImage",
"action": "aws:createImage",
"maxAttempts": 3,
"onFailure": "Abort",
"inputs": {
"InstanceId": "i-123456789",
"ImageName": "AMI Created on{{global:DATE_TIME}}",
"NoReboot": true,
"ImageDescription": "My newly created AMI"
}
}
Inputs
The action supports most create-image API’s parameters. For specific permitted value, please refer to the create-image api documentation.
ImageNameA string literal containing the name of the image.
Required: Yes
InstanceIdA string literal containing the id of the instance.
Required: Yes
BlockDeviceMappingsA map list containing the mappings for the instance.
Required: No
ImageDescriptionA string literal.
Required: No
NoRebootA boolean literal.
Required: No
Outputs
ImageIdA string literals containing the id of the newly created image.
ImageStateA string literals containing the state of the newly created image.
Action aws:deleteImage
You can use this action to delete an existing image.
JSON Sample
{
"name": "deleteMyImage",
"action": "aws:deleteImage",
"maxAttempts": 3,
"timeoutSeconds": 180,
"onFailure": "Abort",
"inputs": {
"ImageId": "ami-1234567890"
}
}
Inputs
The action supports most of delete-image API’s parameters for Lambda service. For specific permitted value, please refer to the delete-image api documentation.
ImageIdA string literal containing the id of the image to be deleted.
Required: Yes
Outputs
None.

