Skip to content

Instantly share code, notes, and snippets.

@NimaSaed
Created January 24, 2023 12:51
Show Gist options
  • Save NimaSaed/d701f1cbcc38f9800974271b7a09bce9 to your computer and use it in GitHub Desktop.
Save NimaSaed/d701f1cbcc38f9800974271b7a09bce9 to your computer and use it in GitHub Desktop.
import boto3
def lambda_handler(event, context):
print("Instance ID")
print("---------------")
print(event["detail"]["resources"][0]["id"])
print("---------------")
ssm = boto3.client('ssm')
# specify the name or ARN of the automation document
document_name = 'AWS-PatchAsgInstance'
# specify the parameters for the automation document
parameters = {
'InstanceId': [event["detail"]["resources"][0]["id"]],
'WaitForReboot' : ['PT5M'],
'WaitForInstance' : ['PT2M']
}
# execute the automation document
response = ssm.start_automation_execution(
DocumentName=document_name,
Parameters=parameters
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment