is it possible to patch ec2 instances based on a schedule through a python script?

Viewed 242

I have no code at the moment, but I am wondering where I can be able to look into to learn how to write a python script that will trigger a patching command on an ec2 instance. Patching should be automated using API calls and boto3 as well, but I am having trouble seeing how to accomplish this.

1 Answers

If you want to patch using a Python script specifically, take a look at create a CloudWatch Event with an event schedule. The target could be a SSM Run Command to execute the Python script on each server (if that's how it works).

You can either create your own document or use the AWS-RunShellScript document.

Alternatively, AWS does have support for automated patching built into by using the SSM Patch Manager which can handle the patching for you.

Related