Complete installation and configuration instructions for CloudWatch AI Agent
Before installing the CloudWatch AI Agent, ensure you have the following requirements:
The CloudWatch AI Agent requires Python 3.13 to be installed on the machine where Terraform will run.
terraform apply). This is required for building the Lambda layer dependencies.
On macOS (using Homebrew):
brew install python@3.13 python3.13 --version
On Ubuntu/Debian:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.13 python3.13-venv python3.13 --version
On Amazon Linux 2023:
sudo dnf install python3.13 python3.13 --version
Verify Installation:
# Should output: Python 3.13.x python3.13 --version # Verify pip is available python3.13 -m pip --version
Install and configure the AWS Command Line Interface:
# Install AWS CLI (if not already installed) curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install # Configure AWS credentials aws configure
Install Terraform version 1.0 or higher:
# Download and install Terraform wget https://releases.hashicorp.com/terraform/1.6.6/terraform_1.6.6_linux_amd64.zip unzip terraform_1.6.6_linux_amd64.zip sudo mv terraform /usr/local/bin/ terraform version
Your AWS IAM user or role needs the following permissions:
The CloudWatch AI Agent uses Amazon Bedrock with Nova Lite for AI-powered alarm analysis. You must request and enable model access before deploying.
Via AWS Console:
us-east-1 regionamazon.nova-lite-v1:0. This is a fast, cost-effective model perfect for CloudWatch alarm analysis.
Via AWS CLI:
# Check current model access status aws bedrock list-foundation-models --region us-east-1 \ --query 'modelSummaries[?contains(modelId, `nova-lite`)].modelId' # Note: Model access must be granted via Console # CLI doesn't support requesting access programmatically
Confirm that Nova Lite is accessible:
# Test Bedrock access
aws bedrock-runtime invoke-model \
--model-id amazon.nova-lite-v1:0 \
--region us-east-1 \
--body '{"messages":[{"role":"user","content":[{"text":"Hello"}]}],"inferenceConfig":{"maxTokens":100,"temperature":0.7}}' \
output.json
# Check the response
cat output.json
Amazon Bedrock is available in specific regions. The CloudWatch AI Agent uses:
| Component | Region | Configurable |
|---|---|---|
| Lambda Function | Your chosen region | Yes (via Terraform variables) |
| Bedrock API | us-east-1 (default) | Yes (via bedrock_region variable) |
| Nova Lite Model | Same as Bedrock API | — |
After subscribing, retrieve your license key from your Account Dashboard.
Create a new Terraform configuration file (e.g., main.tf) and declare the CloudWatch AI Agent module:
module "cloudwatch_ai_agent" {
source = "api.aiopscrew.com/v1/module"
# License key from your account dashboard
license_key = "cwa_live_xxxxxxxxxxxxx"
# Required: Slack webhook for alert notifications
slack_webhook_url = "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
# Optional: Customize deployment
function_name = "cloudwatch-alert-ai-agent"
bedrock_model_id = "amazon.nova-lite-v1:0"
bedrock_region = "us-east-1"
lambda_timeout = 300
lambda_memory_size = 512
environment = "production"
}
license_key value with your actual license key from your account dashboard. The module cannot be downloaded without a valid, active subscription.
Initialize Terraform to download the module and providers:
# Initialize Terraform - downloads the module from API terraform init # Validate configuration terraform validate
terraform init, Terraform will authenticate with the API using your license key and download the module. Your subscription must be active.
# Review what will be created terraform plan
Expected resources to be created:
# Apply Terraform configuration terraform apply # Confirm with 'yes' when prompted
After deployment, retrieve the SNS topic ARN for configuring CloudWatch alarms:
# Get the SNS topic ARN terraform output -raw cloudwatch_ai_agent_sns_topic_arn
Add the SNS topic to your CloudWatch alarms:
# Example: Update existing alarm aws cloudwatch put-metric-alarm \ --alarm-name "high-cpu-usage" \ --alarm-description "CPU above 80%" \ --metric-name CPUUtilization \ --namespace AWS/EC2 \ --statistic Average \ --period 300 \ --threshold 80 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 2 \ --alarm-actions $(terraform output -raw sns_topic_arn)
The Lambda function uses these environment variables (automatically configured by Terraform):
| Variable | Description | Default |
|---|---|---|
SLACK_WEBHOOK_URL |
Slack incoming webhook URL | Required (no default) |
BEDROCK_MODEL_ID |
Bedrock model identifier | amazon.nova-lite-v1:0 |
BEDROCK_REGION |
AWS region for Bedrock | us-east-1 |
To use a different Bedrock model:
bedrock_model_id in terraform.tfvarsterraform applyCompatible models:
amazon.nova-lite-v1:0 - Fast, cost-effective (recommended)amazon.nova-pro-v1:0 - More capable, higher costanthropic.claude-3-haiku-* - Alternative providerError: python3.13: command not found
Solution:
# Ensure Python 3.13 is in PATH which python3.13 # If not found, install Python 3.13 (see Prerequisites section) # Then verify: python3.13 --version
Error: AccessDeniedException: You don't have access to the model
Solution:
bedrock:InvokeModelError: Issues during layer build or dependency installation
Solution:
# Clean build artifacts rm -rf modules/cloudwatch-slack-alert/.build/ # Re-run Terraform terraform apply
Checklist:
aws logs tail /aws/lambda/your-function-name --follow# Stream logs in real-time aws logs tail /aws/lambda/cloudwatch-alert-ai-agent --follow # Search for errors aws logs filter-log-events \ --log-group-name /aws/lambda/cloudwatch-alert-ai-agent \ --filter-pattern "ERROR"