Skip to content

Instantly share code, notes, and snippets.

@lrakai
lrakai / lambda-aws-ssm-run-command-on-ec2-instance.py
Last active January 9, 2024 16:29
Run commands on EC2 instances using Lambda and Systems Manager (SendCommand)
import boto3
import botocore
import time
def handler(event=None, context=None):
client = boto3.client('ssm')
instance_id = 'i-07362a00952fca213' # hard-code for example
response = client.send_command(