 <p>Using <a href="http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html" rel="nofollow">Amazon EC2 Simple Systems Manager</a>, you can configure an SSM document to run a script on an instance, and pass that script a parameter. The Lambda instance would need to run the SSM send-command, targeting the instance by its instance id.</p> <p>Sample SSM document: run_my_example.json:</p> <pre><code>{ "schemaVersion": "1.2", "description": "Run shell script to launch.", "parameters": { "taskId":{ "type":"String", "default":"", "description":"(Required) the Id of the task to run", "maxChars":16 } }, "runtimeConfig": { "aws:runShellScript": { "properties": [ { "id": "0.aws:runShellScript", "runCommand": ["run_my_example.sh"] } ] } } } </code></pre> <p>The above SSM document accepts taskId as a parameter.</p> <p>Save this document as a JSON file, and call create-document using the AWS CLI:</p> <pre><code>aws ssm create-document --content file:///tmp/run_my_example.json --name "run_my_example" </code></pre> <p>You can review the description of the SSM document by calling <code>describe-document</code>:</p> <pre><code>aws ssm describe-document --name "run_my_example" </code></pre> <p>You can specify the taskId parameter and run the command by using the document name with the <code>send-command</code></p> <pre><code>aws ssm send-command --instance-ids i-12345678 --document-name "run_my_example" --parameters --taskid=123456 </code></pre> <p><strong>NOTES</strong></p> <ul> <li><p>Instances must be running the <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/remote-commands-prereq.html" rel="nofollow">latest version of the SSM agent</a>.</p></li> <li><p>You will need to have some logic in the Lambda script to identify the instance ids of the server EG look up the instance id of a specifically tagged instance.</p></li> </ul>