Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

You need to watch for EC2 instance state changes and post to Slack in near real time. What do you build?

IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Event-driven, not polling.

What I'd do →

  1. EventBridge rule on EC2 Instance State-change Notification targeting a Python Lambda.
  2. Lambda reads detail.instance-id and detail.state, looks up the Name and Owner tags with describe_instances, posts to Slack.
  3. Slack webhook URL in Secrets Manager, cached across invocations.
  4. DLQ and retry settings on the target.

Why → Events cost nothing when idle and arrive within seconds; polling wastes API calls.

Interview tip → "Event-driven over polling" is the principle.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation