Search code examples
aws-ssm

Run Python script on EC2 instance via SSM


I can run shell commands on an EC2 instance via SSM SendCommand w/ AWS-RunShellScript document. The same can be done for PowerShell scripts w/ AWS-RunPowerShellScript.

There is AWS-RunRemoteScript which can run Python script from S3 or GitHub, but I don't see anything like AWS-RunPythonScript that can run embedded Python script.

Does this simply not exist?


Solution

  • Yes, it simply does not exist.

    AWS SSM has a fairly straightforward structure - at the very bottom there are finite and quite small number of operations, which documents can run - https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-schemas-features.html

    Notice that AWS-RunRemoteScript essentially just run aws:downloadContent and then aws:runPowerShellScript aws:runShellScript which are also used by AWS-RunShellScript and AWS-RunPowerShellScript.