AWS Builder Center

How I Deploy OpenClaw Agent to Monitor My EC2 Instances

A practical look at how I automated EC2 instances status monitoring using OpenClaw Agent.

Cloud Engineer

Overview

Tracking the status of EC2 instances requires more attention than expected, especially in non-critical environments. I have a sandbox environment with intentionally intermittent resources. I don't need my EC2 instances running 24/7, but I want them running on demand. The problem is I sometimes forget to shut down the running EC2 instances, so I want a system that can monitor and notify me about the EC2 instances status automatically.
In this article, I explain how I deploy OpenClaw Agent that uses Amazon Bedrock as a provider to address my use case above.
Disclaimer: All contents written in this blog are solely my personal opinion and do not represent my employer's opinion.

The Infrastructure

I deployed the infrastructure by referencing the aws-samples/sample-OpenClaw-on-AWS-with-BedrockĀ  repository.
It provides a One-Click Deploy option that simplifies the deployment, from provisioning infrastructure resources to OpenClaw installation. This suits my use case as I don't have specific requirements and I want a simple installation. It also provides a CloudFormation stack template, which enables infrastructure management through code.
Full deployment instructions can be found in the repository linked above.

Deployment & Configuration

Step 1: For initial deployment, please follow Deployment Guide in Deployment.mdĀ  in the repository. In my case, I used the One-Click DeploymentĀ  and used region US West (Oregon)/us-west-2.
Step 2: Go to CloudFormation page, find your stack. Ensure the last status of deployment is CREATE_COMPLETE.
Step 3: Connect your preferred messaging platforms as guided in the Deployment.mdĀ . In my case, I used Telegram.
Step 4: OpenClaw EC2 instance server has been provided with IAM Instance Role as referred to the clawdbot-bedrock.yamlĀ  CloudFormation template. In my case, because I want the agent to have access to EC2 instances management, I need to attach additional permission. Because this is only a sandbox environment, I attached the AWS managed policy AmazonEC2FullAccess.
āš ļø Note: AmazonEC2FullAccess is used here for sandbox convenience. Always apply least privilege permissions in production.
1
2
3
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore'
- 'arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy'
1
2
3
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore'
- 'arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy'
Step 5: For the CloudFormation update, I created a change set to reflect what will be changed. In my case, I didn't want to override any existing parameter values and I used S3 as source for template URL reference. I used AWS CLI for both operations.
Step 6: Upload the updated clawdbot-bedrock.yaml to your S3 bucket.
1
aws s3 cp clawdbot-bedrock.yaml s3://my-cfn-template-bucket/clawdbot-bedrock.yaml
Step 7: Create a change set without overriding any existing parameter values.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
aws cloudformation create-change-set \
--stack-name openclaw-bedrock \
--template-url https://s3.us-west-2.amazonaws.com/my-cfn-template-bucket/clawdbot-bedrock.yaml \
--change-set-name my-cfn-change-set \
--capabilities CAPABILITY_IAM \
--parameters \
ParameterKey=KeyPairName,UsePreviousValue=true \
ParameterKey=CreateVPCEndpoints,UsePreviousValue=true \
ParameterKey=EnableDataProtection,UsePreviousValue=true \
ParameterKey=OpenClawModel,UsePreviousValue=true \
ParameterKey=InstanceType,UsePreviousValue=true \
ParameterKey=AllowedSSHCIDR,UsePreviousValue=true \
ParameterKey=EnableSandbox,UsePreviousValue=true \
ParameterKey=OpenClawVersion,UsePreviousValue=true \
--region us-west-2
Step 8: Go to CloudFormation stack, find your latest stack change set. Ensure the resource changes are expected. In this case, AmazonEC2FullAccess should be added as policy used by OpenClawInstanceRole. If all changes are expected, continue to execute the change set.
Step 9: Ensure the status of last deployment is UPDATE_COMPLETE.
Step 10: Connect to your OpenClaw instance. Add OpenClaw cron to set automatic scheduled message that checks the status of EC2 instances. In my case, I want the messages to be sent every day at 0:00 UTC and query the EC2 instances residing in ap-southeast-1 region. I curated the output of AWS CLI command used to list EC2 instances to only show Instance ID, Name, Type, State.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
openclaw cron add \
--cron "0 0 * * *" \
--name "ec2-daily-report" \
--description "Daily EC2 status report for ap-southeast-1" \
--message "List all EC2 instances in ap-southeast-1 and format as markdown table with columns: Instance ID, Name, Type, State. Use this exact AWS CLI command: aws ec2 describe-instances --region ap-southeast-1 --output text --query \"Reservations[*].Instances[*].[InstanceId,Tags[?Key==\\\\`Name\\\\`]|[0].Value,InstanceType,State.Name]\""
--channel telegram \
--to "<your_telegram_channel_id>" \
--session isolated \
--announce

šŸ¦ž OpenClaw 2026.3.24 (cff6dc9) — I don't judge, but your missing API keys are absolutely judging you.

│
ā—‡
{
"id": "2e617bf0-054f-457d-88c6-57d3dafbe274",
"name": "ec2-daily-report",
"description": "Daily EC2 status report for ap-southeast-1",
"enabled": true,
"createdAtMs": 1779039611725,
"updatedAtMs": 1779039611725,
"schedule": {
"kind": "cron",
"expr": "0 0 * * *"
},
"sessionTarget": "isolated",
"wakeMode": "now",
"payload": {
"kind": "agentTurn",
"message": "List all EC2 instances in ap-southeast-1 and format as markdown table with columns: Instance ID, Name, Type, State. Use this exact AWS CLI command: aws ec2 describe-instances --region ap-southeast-1 --output text --query \"Reservations[*].Instances[*].[InstanceId,Tags[?Key==\\\\`Name\\\\`]|[0].Value,InstanceType,State.Name]\""
},
"delivery": {
"mode": "announce",
"channel": "telegram",
"to": "<your_telegram_channel_id>"
},
"state": {
"nextRunAtMs": 1779062400000
}
}
Step 11: You can verify the creation of OpenClaw cron by running this command:
1
2
3
4
5
6
7
8
$ openclaw cron list

šŸ¦ž OpenClaw 2026.3.24 (cff6dc9) — If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.

│
ā—‡
ID Name Schedule Next Last Status Target Agent ID Model
2e617bf0-054f-457d-88c6-57d3dafbe274 ec2-daily-report cron 0 0 * * * (exact) in 6h - idle isolated - -
Step 12: At scheduled time, messages containing the list of EC2 instances will be sent to Telegram.

Conclusion

We have reached the last section of this blog. Here are the key takeaways:
  1. How OpenClaw Agent can help automate monitoring of EC2 instance status.
  2. Simplified installation and infrastructure maintenance using CloudFormation template from aws-samples/sample-OpenClaw-on-AWS-with-BedrockĀ .
  3. Monitoring helps prevent wasted costs from over-provisioned EC2 instances.
Please comment if you have any suggestions, feedback, or thoughts.
Hope this article will benefit you. Thank you!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article