Created
January 24, 2023 12:51
-
-
Save NimaSaed/d701f1cbcc38f9800974271b7a09bce9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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