How to Manage EC2 Instances Without Writing Scripts

Learn how to manage AWS EC2 instances using natural language commands instead of maintaining complex scripts. AI-powered infrastructure management with Claude on Amazon Bedrock - practical examples and real results.

7 min read
AWS EC2 AI

How to Manage EC2 Instances Without Writing Scripts

If you’re managing EC2 instances, you probably have a folder full of scripts. PowerShell for Windows servers, Python for AWS API calls, Bash for Linux boxes. Each one carefully crafted, documented (maybe), and increasingly difficult to maintain.

Here’s the problem: scripts break. AWS updates an API, a Python library gets deprecated, or a new team member doesn’t understand the PowerShell syntax. Suddenly you’re spending more time maintaining your automation than actually managing infrastructure.

What if you could just… ask for what you need? In plain English. No syntax to remember, no scripts to maintain, no tribal knowledge to preserve.

That’s what AI-powered infrastructure management delivers. Let me show you how it works.

The Script Maintenance Problem

First, let’s be honest about what traditional automation looks like.

Example: Checking Instance Health

The PowerShell way:

# Check EC2 health across all regions
$regions = Get-EC2Region | Select-Object -ExpandProperty RegionName

foreach ($region in $regions) {
    Set-DefaultAWSRegion -Region $region

    $instances = Get-EC2Instance

    foreach ($reservation in $instances) {
        foreach ($instance in $reservation.Instances) {
            $status = Get-EC2InstanceStatus -InstanceId $instance.InstanceId

            if ($status.Status.Status -ne "ok") {
                Write-Host "UNHEALTHY: $($instance.InstanceId) in $region"
                Write-Host "  System Status: $($status.SystemStatus.Status)"
                Write-Host "  Instance Status: $($status.InstanceStatus.Status)"
            }
        }
    }
}

Issues with this approach:

  • 20+ lines of code for a simple check
  • Need to remember PowerShell syntax
  • Have to handle AWS regions manually
  • Error handling not shown (add another 10 lines)
  • New team members need training
  • Breaks when AWS changes the API

The AI-Powered Way

You: "Show me unhealthy EC2 instances across all regions"

AI: Found 2 unhealthy instances:

┌──────────────────────┬───────────┬─────────────────┬──────────────┐
│ Instance ID          │ Region    │ Name            │ Issue        │
├──────────────────────┼───────────┼─────────────────┼──────────────┤
│ i-abc123             │ us-east-1 │ web-server-03   │ Status check │
│ i-def456             │ eu-west-1 │ api-server-12   │ System check │
└──────────────────────┴───────────┴─────────────────┴──────────────┘

Would you like me to investigate what's causing the issues?

Benefits:

  • Natural language - no syntax to remember
  • Works immediately - no script to write
  • Handles all regions automatically
  • Results formatted for humans
  • Can drill deeper with follow-up questions

See the difference? Let’s look at how this actually works.

How AI-Powered EC2 Management Works

The technology behind this is Amazon Bedrock with Claude - Anthropic’s AI model that understands both natural language and technical infrastructure.

What Happens Behind the Scenes

When you ask: “Show me unhealthy EC2 instances”

  1. Claude understands your intent

    • You want instance health information
    • Across your infrastructure
    • Focused on problems
  2. Generates the right code

    • Chooses PowerShell/Python/Bash based on context
    • Includes proper error handling
    • Handles AWS credentials and regions
  3. Executes safely

    • Read-only operations run automatically
    • Changes require your approval
    • All actions are logged
  4. Presents results clearly

    • Formatted tables, not raw JSON
    • Highlights what matters
    • Suggests next steps

Real Example: Troubleshooting a Slow Instance

Here’s how a real troubleshooting session looks:

You: "Why is i-abc123 so slow?"

AI: Checking instance i-abc123 (web-server-03)...

Found the issue:
🔴 CPU: 95% utilization (past 1 hour)
🟢 Memory: 42% used (normal)
🟢 Network: Normal traffic
🔴 Disk I/O: Very high read operations

Top CPU processes:
1. mysqld - 78% CPU
2. apache2 - 12% CPU

Root cause: MySQL queries without proper indexes.
Recent slow queries found in mysql-slow.log

Recommendations:
A) Add indexes to fix slow queries (I can show you which ones)
B) Increase instance size from t3.medium → t3.large
C) Move database to RDS for better performance

What would you like to do?

You: Show me the slow queries

AI: Top 3 slow queries from the last hour:

1. SELECT * FROM orders WHERE user_id = X
   Avg time: 8.2 seconds | Times run: 1,247
   Issue: No index on user_id column

2. SELECT * FROM products JOIN categories...
   Avg time: 3.1 seconds | Times run: 892
   Issue: Full table scan on products table

3. SELECT COUNT(*) FROM logs WHERE date > ...
   Avg time: 2.4 seconds | Times run: 445
   Issue: No index on date column

I can generate the ALTER TABLE statements to add these indexes.
Want me to show you the commands?

This is conversational infrastructure management. No scripts needed, no AWS console clicking, just describing what you need.

Practical Use Cases

Let me show you some real scenarios where this beats traditional scripting.

1. Quick Health Checks

Traditional approach: Run your health check script, parse output, correlate issues AI approach: “Are all my production servers healthy?”

The AI checks:

  • Instance status
  • System checks
  • Application health (if monitoring configured)
  • Recent errors in logs
  • Network connectivity

And tells you what’s actually wrong, not just raw metrics.

2. Cost Investigation

Traditional approach: Write AWS Cost Explorer queries, export data, analyze in spreadsheets AI approach: “Which EC2 instances are costing the most this month?”

Get instant answers like:

  • Top 10 instances by cost
  • Suggestions for rightsizing
  • Instances running 24/7 that could be scheduled
  • Unused Elastic IPs still charging you

3. Security Audits

Traditional approach: Multiple AWS CLI commands, parse JSON, compare against compliance docs AI approach: “Show me any security groups allowing SSH from 0.0.0.0/0”

Claude understands security best practices and can:

  • Find overly permissive security groups
  • Identify unencrypted EBS volumes
  • Spot instances without recent patches
  • Check for compliance violations

4. Incident Response

Traditional approach: Wake up at 2 AM, VPN in, run diagnostic scripts, read logs, troubleshoot AI approach: Get alerted in Teams, ask “What’s wrong with the production servers?”

The AI can:

  • Diagnose issues from symptoms
  • Check logs automatically
  • Suggest remediation steps
  • Execute fixes with your approval
  • Document what happened

All from your phone in Microsoft Teams.

Multi-Language Support: The Secret Weapon

Here’s something that makes AI-powered management incredibly powerful: it speaks every language.

Need to manage Windows servers? Claude generates PowerShell. Need AWS API automation? Claude writes Python. Need Linux server commands? Claude outputs Bash.

Example scenario:

You: "Check disk space on all Windows servers and clean up logs if any are over 80%"

AI: I'll need to:
1. Query EC2 for Windows instances (AWS SDK - Python)
2. Send PowerShell commands via SSM Run Command
3. Check disk space (PowerShell)
4. Compress old logs if needed (PowerShell)

Proceeding...

Results:
✓ web-server-01: 62% used (healthy)
✓ web-server-02: 58% used (healthy)
⚠ web-server-03: 87% used - Compressed 15GB of logs → now 68%
✓ api-server-01: 71% used (healthy)

All servers now healthy.

Claude generated and executed:

  • Python code to query AWS
  • SSM Run Command to execute on instances
  • PowerShell commands to check disk space
  • PowerShell scripts to compress logs

You didn’t need to write any of it.

This matters because:

  • You don’t need to master every language
  • New team members don’t need extensive training
  • The “right tool” gets used automatically
  • Your scripts don’t become technical debt

Learn more about multi-language automation in our guide on PowerShell REST API integration.

Safety First: Approval Workflows

A valid concern: “What if the AI does something destructive?”

AI-powered infrastructure tools like Ohlala SmartOps include built-in safety mechanisms with approval workflows:

  • Read-only operations (queries, health checks) → run automatically
  • Modifications (start/stop, config changes) → require approval
  • Destructive actions (terminate, delete) → require explicit confirmation

This means you can safely ask questions and investigate issues without worrying about accidental changes. The AI explains what it will do before making any modifications, and you approve each step.

For a deep dive into how AI safety and approval workflows work, see our dedicated guide on this topic (coming soon).

Getting Started

Want to try AI-powered EC2 management? Here’s how to get started:

1. Start with Read-Only Operations

Begin by using AI for:

  • Health checks
  • Cost analysis
  • Security audits
  • Log investigation

Build trust with safe operations before moving to changes.

2. Integrate with Microsoft Teams

Running operations in Teams provides:

  • Visibility: Everyone sees what’s happening
  • Collaboration: Team members can contribute to troubleshooting
  • Documentation: Chat history = operations log
  • Accessibility: Works on desktop and mobile

Learn why Teams is ideal for DevOps in our FAQ.

3. Set Up Approval Workflows

Define what requires approval:

  • Junior engineers: Approve everything except queries
  • Senior engineers: Approve production changes
  • On-call: Emergency override permissions

4. Monitor and Learn

Track:

  • What operations are being run
  • Time saved vs writing scripts
  • Incidents resolved faster
  • Team adoption rate

The Reality Check

Is this really better than scripts?

For some scenarios - absolutely. For others - scripts still make sense.

AI-powered management excels at:

  • One-off investigations
  • Complex troubleshooting
  • Questions you can’t pre-script
  • Onboarding new team members
  • Rapid incident response

Traditional scripts still win for:

  • Highly repetitive scheduled tasks
  • Ultra-precise control requirements
  • Air-gapped environments
  • Situations requiring millisecond performance

The best approach? Use both. Let AI handle the unexpected, keep scripts for predictable automation.

Check our guides on PowerShell error handling and logging best practices to build better scripts when you need them.

Next Steps

Ready to try AI-powered EC2 management?

Option 1: Start with Ohlala SmartOps

Option 2: Build Your Own

Questions?


The era of maintaining hundreds of infrastructure scripts is ending. Natural language infrastructure management is here, and it works better than you’d expect.

Related Articles:

Ready to Automate Your EC2 Management?

Get 24/7 AI-powered infrastructure assistance in Microsoft Teams. SmartOps helps your team manage, monitor, and optimize EC2 instances for just $199/month.