News

CloudClaw: Control AWS EC2 Instances from WhatsApp Using Natural Language and OpenClaw

CloudClaw: Control AWS EC2 Instances from WhatsApp Using Natural Language and OpenClaw

Tired of logging into the AWS console at 2 AM to restart a crashed server? CloudClaw offers an elegant solution: control your AWS EC2 virtual machines directly from WhatsApp using natural language. This innovative project transforms cloud resource management into a simple chat interaction.

CloudClaw’s core functionality allows users to type commands like "stop vm," "check cpu on web server," or "list all my instances" into WhatsApp. OpenClaw then handles the entire process, parsing the request, executing the necessary actions, and replying with the results. The workflow is meticulously designed: A WhatsApp message travels through the OpenClaw gateway (typically running on macOS via the Linked Devices protocol) and is then routed to a custom cloud-manager AgentSkill. This Skill invokes the aws_manager.py script, which leverages the AWS SDK (boto3) to interact with AWS EC2 and CloudWatch APIs. The operation's outcome is then sent back to the WhatsApp chat, and a local live dashboard (localhost:8080) automatically updates every 10 seconds.

OpenClaw's underlying Large Language Model (LLM) understands intent, not just exact command matches, enabling flexibility such as recognizing both "boot up my prod box" and "launch web-server" as valid commands. CloudClaw supports a range of operations, including:

  • Start VM / Launch Server: Initiates an EC2 instance, polls until it's running, and returns its IP address.
  • Stop VM / Shut Down Server: Gracefully stops the instance and confirms when it's in a stopped state.
  • Restart VM / Reboot Server: Reboots the instance and provides an estimated time of arrival for its return to service.
  • List VMs / Show All Servers: Displays all EC2 instances, including their status, type, and IP address.
  • Check CPU: Retrieves CPU utilization percentage over 5 minutes, 1 hour, or 24 hours from CloudWatch.
  • Check Memory: Gathers RAM usage data via the CloudWatch Agent.
  • Status: Provides an AWS cloud health report.

OpenClaw serves as the essential backbone for CloudClaw. Here's how it empowers the project:

1. Custom AgentSkill — cloud-manager/SKILL.md

OpenClaw’s Skills system enables developers to define a SKILL.md file that describes to the agent what a tool does, when to use it, and how to call it. This file acts as CloudClaw's intelligent core, instructing OpenClaw on:

  • Which messages should trigger cloud operations, defined by natural language trigger rules.
  • Whether to route requests to AWS, GCP, or both.
  • How to invoke Python scripts via OpenClaw's built-in exec tool.
  • How to format WhatsApp-friendly replies.

For example, the metadata section of the SKILL.md defines the skill's name, description, user-invocability, and crucial trigger phrases:

---
name: cloud-manager
description: >
Manages AWS EC2 instances and GCP Compute Engine instances via natural language.
user-invocable: true
triggers:
- start vm
- stop vm
- restart vm
- list vms
- check cpu
- check memory
- cloud status
metadata:
openclaw:
requires:
bins: ["python3"]
---

The remaining portion of the SKILL.md outlines NLP routing rules and response formatting instructions in plain Markdown, which OpenClaw interprets to execute precise actions.

2. Python Script — boto3

OpenClaw's exec tool allows skills to run shell commands and Python scripts. For CloudClaw, the aws_manager.py script was developed to utilize the boto3 library for the following functions:

  • Executing ec2.start_instances(), ec2.stop_instances(), and ec2.reboot_instances() to manage instance lifecycle.
  • Using ec2.describe_instances() for listing comprehensive instance details.
  • Calling cloudwatch.get_metric_statistics() to retrieve CPU and memory metrics.
  • Implementing polling loops to wait for state changes and return final results.

The script is designed to return clean, emoji-formatted output, optimized for clear presentation within WhatsApp chats.

↗ Read original source