Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tuts/179-cloudwatch-anomaly-detection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Cloudwatch Anomaly Detection

An AWS CLI tutorial that demonstrates Cloudwatch operations.

## Running

```bash
bash cloudwatch-anomaly-detection.sh
```

To auto-run with cleanup:

```bash
echo 'y' | bash cloudwatch-anomaly-detection.sh
```

## What it does

1. Publishing baseline metrics
2. Creating anomaly detector
3. Creating anomaly detection alarm
4. Describing alarm

## Resources created

- Anomaly Detector
- Metric Alarm
- Metric Data

The script prompts you to clean up resources when it finishes.

## Cost

Free tier eligible for most operations. Clean up resources after use to avoid charges.

## Related docs

- [AWS CLI cloudwatch reference](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/index.html)

8 changes: 8 additions & 0 deletions tuts/179-cloudwatch-anomaly-detection/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 179-cloudwatch-anomaly-detection

## Shell (CLI script)

### 2026-04-14 v1 published
- Type: functional
- Initial version

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Cloudwatch Anomaly Detection

## Prerequisites

1. AWS CLI installed and configured (`aws configure`)
2. Appropriate IAM permissions for the AWS services used

## Step 1: Publishing baseline metrics

The script handles this step automatically. See `cloudwatch-anomaly-detection.sh` for the exact CLI commands.

## Step 2: Creating anomaly detector

The script handles this step automatically. See `cloudwatch-anomaly-detection.sh` for the exact CLI commands.

## Step 3: Creating anomaly detection alarm

The script handles this step automatically. See `cloudwatch-anomaly-detection.sh` for the exact CLI commands.

## Step 4: Describing alarm

The script handles this step automatically. See `cloudwatch-anomaly-detection.sh` for the exact CLI commands.

## Cleanup

The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/ad.log") 2>&1
REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); NS="Tutorial/AD-${RANDOM_ID}"; ALARM="tut-ad-alarm-${RANDOM_ID}"
cleanup() { echo ""; echo "Cleaning up..."; aws cloudwatch delete-alarms --alarm-names "$ALARM" 2>/dev/null && echo " Deleted alarm"; aws cloudwatch delete-anomaly-detector --namespace "$NS" --metric-name Latency --stat Average 2>/dev/null && echo " Deleted detector"; rm -rf "$WORK_DIR"; echo "Done."; }
echo "Step 1: Publishing baseline metrics"
for i in $(seq 1 20); do aws cloudwatch put-metric-data --namespace "$NS" --metric-name Latency --value $((50 + RANDOM % 20)) --unit Milliseconds; done
echo " Published 20 data points"
echo "Step 2: Creating anomaly detector"
aws cloudwatch put-anomaly-detector --namespace "$NS" --metric-name Latency --stat Average 2>/dev/null && echo " Detector created" || echo " Detector creation pending"
echo "Step 3: Creating anomaly detection alarm"
aws cloudwatch put-metric-alarm --alarm-name "$ALARM" --namespace "$NS" --metric-name Latency --comparison-operator LessThanLowerOrGreaterThanUpperThreshold --evaluation-periods 1 --threshold-metric-id ad1 --metrics '[{"Id":"m1","MetricStat":{"Metric":{"Namespace":"'"$NS"'","MetricName":"Latency"},"Period":60,"Stat":"Average"},"ReturnData":true},{"Id":"ad1","Expression":"ANOMALY_DETECTION_BAND(m1,2)","ReturnData":true}]' 2>/dev/null && echo " Alarm created" || echo " Alarm creation requires more data"
echo "Step 4: Describing alarm"
aws cloudwatch describe-alarms --alarm-names "$ALARM" --query 'MetricAlarms[0].{Name:AlarmName,State:StateValue}' --output table 2>/dev/null || echo " No alarm"
echo ""; echo "Tutorial complete."
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
29 changes: 29 additions & 0 deletions tuts/189-cloudwatch-contributor-insights/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Cloudwatch Contributor Insights

A read-only script that queries Cloudwatch resources and displays information.

## Running

```bash
bash cloudwatch-contributor-insights.sh
```

## What it does

1. Listing existing rules
2. Listing log groups for analysis
3. Getting metric widget image (base64)

## Resources created

None — this script is read-only.

## Cost

No cost. This script only reads existing resources.

## Related docs

- [AWS CLI cloudwatch reference](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/index.html)
- [AWS CLI logs reference](https://docs.aws.amazon.com/cli/latest/reference/logs/index.html)

8 changes: 8 additions & 0 deletions tuts/189-cloudwatch-contributor-insights/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 189-cloudwatch-contributor-insights

## Shell (CLI script)

### 2026-04-14 v1 published
- Type: functional
- Initial version

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Cloudwatch Contributor Insights

## Prerequisites

1. AWS CLI installed and configured (`aws configure`)
2. Appropriate IAM permissions for the AWS services used

## Step 1: Listing existing rules

The script handles this step automatically. See `cloudwatch-contributor-insights.sh` for the exact CLI commands.

## Step 2: Listing log groups for analysis

The script handles this step automatically. See `cloudwatch-contributor-insights.sh` for the exact CLI commands.

## Step 3: Getting metric widget image (base64)

The script handles this step automatically. See `cloudwatch-contributor-insights.sh` for the exact CLI commands.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/tut.log") 2>&1
REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
echo "Step 1: Listing existing rules"
aws cloudwatch describe-insight-rules --query 'InsightRules[:5].{Name:Name,State:State}' --output table 2>/dev/null || echo " No insight rules"
echo "Step 2: Listing log groups for analysis"
aws logs describe-log-groups --limit 5 --query 'logGroups[].{Name:logGroupName,Stored:storedBytes}' --output table
echo "Step 3: Getting metric widget image (base64)"
aws cloudwatch get-metric-widget-image --metric-widget '{"metrics":[["AWS/EC2","CPUUtilization"]],"period":300,"stat":"Average","region":"us-east-1","title":"EC2 CPU"}' --query 'MetricWidgetImage' --output text | head -c 50
echo "..."
echo ""; echo "Tutorial complete. No resources created — read-only."
rm -rf "$WORK_DIR"
39 changes: 39 additions & 0 deletions tuts/195-cloudwatch-composite-alarms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Cloudwatch Composite Alarms

An AWS CLI tutorial that demonstrates Cloudwatch operations.

## Running

```bash
bash cloudwatch-composite-alarms.sh
```

To auto-run with cleanup:

```bash
echo 'y' | bash cloudwatch-composite-alarms.sh
```

## What it does

1. Publishing metrics
2. Creating metric alarms
3. Creating composite alarm
4. Describing composite alarm

## Resources created

- Composite Alarm
- Metric Alarm
- Metric Data

The script prompts you to clean up resources when it finishes.

## Cost

Free tier eligible for most operations. Clean up resources after use to avoid charges.

## Related docs

- [AWS CLI cloudwatch reference](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/index.html)

8 changes: 8 additions & 0 deletions tuts/195-cloudwatch-composite-alarms/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 195-cloudwatch-composite-alarms

## Shell (CLI script)

### 2026-04-14 v1 published
- Type: functional
- Initial version

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Cloudwatch Composite Alarms

## Prerequisites

1. AWS CLI installed and configured (`aws configure`)
2. Appropriate IAM permissions for the AWS services used

## Step 1: Publishing metrics

The script handles this step automatically. See `cloudwatch-composite-alarms.sh` for the exact CLI commands.

## Step 2: Creating metric alarms

The script handles this step automatically. See `cloudwatch-composite-alarms.sh` for the exact CLI commands.

## Step 3: Creating composite alarm

The script handles this step automatically. See `cloudwatch-composite-alarms.sh` for the exact CLI commands.

## Step 4: Describing composite alarm

The script handles this step automatically. See `cloudwatch-composite-alarms.sh` for the exact CLI commands.

## Cleanup

The script prompts you to clean up all created resources. If you need to clean up manually, check the script log for the resource names that were created.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/tut.log") 2>&1
REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); NS="Tutorial/Comp-${RANDOM_ID}"; A1="tut-cpu-${RANDOM_ID}"; A2="tut-mem-${RANDOM_ID}"; COMP="tut-composite-${RANDOM_ID}"
cleanup() { echo "Cleaning up..."; aws cloudwatch delete-alarms --alarm-names "$COMP" "$A1" "$A2" 2>/dev/null && echo " Deleted alarms"; rm -rf "$WORK_DIR"; echo "Done."; }
echo "Step 1: Publishing metrics"
for i in $(seq 1 5); do aws cloudwatch put-metric-data --namespace "$NS" --metric-data "[{\"MetricName\":\"CPU\",\"Value\":$((RANDOM%100)),\"Unit\":\"Percent\"},{\"MetricName\":\"Memory\",\"Value\":$((RANDOM%100)),\"Unit\":\"Percent\"}]"; done
echo "Step 2: Creating metric alarms"
aws cloudwatch put-metric-alarm --alarm-name "$A1" --namespace "$NS" --metric-name CPU --statistic Average --period 60 --threshold 80 --comparison-operator GreaterThanThreshold --evaluation-periods 1
aws cloudwatch put-metric-alarm --alarm-name "$A2" --namespace "$NS" --metric-name Memory --statistic Average --period 60 --threshold 80 --comparison-operator GreaterThanThreshold --evaluation-periods 1
echo "Step 3: Creating composite alarm"
aws cloudwatch put-composite-alarm --alarm-name "$COMP" --alarm-rule "ALARM(\"$A1\") AND ALARM(\"$A2\")"
echo " Composite alarm triggers when BOTH CPU and Memory are high"
echo "Step 4: Describing composite alarm"
aws cloudwatch describe-alarms --alarm-names "$COMP" --alarm-types CompositeAlarm --query 'CompositeAlarms[0].{Name:AlarmName,Rule:AlarmRule,State:StateValue}' --output table
echo ""; echo "Tutorial complete."
echo "Do you want to clean up? (y/n): "; read -r C; [[ "$C" =~ ^[Yy]$ ]] && cleanup
27 changes: 27 additions & 0 deletions tuts/210-dynamodb-list-tables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dynamodb List Tables

A read-only script that queries Dynamodb resources and displays information.

## Running

```bash
bash dynamodb-list-tables.sh
```

## What it does

1. Listing tables
2. Table details

## Resources created

None — this script is read-only.

## Cost

No cost. This script only reads existing resources.

## Related docs

- [AWS CLI dynamodb reference](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html)

8 changes: 8 additions & 0 deletions tuts/210-dynamodb-list-tables/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 210-dynamodb-list-tables

## Shell (CLI script)

### 2026-04-14 v1 published
- Type: functional
- Initial version

15 changes: 15 additions & 0 deletions tuts/210-dynamodb-list-tables/dynamodb-list-tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Dynamodb List Tables

## Prerequisites

1. AWS CLI installed and configured (`aws configure`)
2. Appropriate IAM permissions for the AWS services used

## Step 1: Listing tables

The script handles this step automatically. See `dynamodb-list-tables.sh` for the exact CLI commands.

## Step 2: Table details

The script handles this step automatically. See `dynamodb-list-tables.sh` for the exact CLI commands.

8 changes: 8 additions & 0 deletions tuts/210-dynamodb-list-tables/dynamodb-list-tables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/tut.log") 2>&1
REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
echo "Step 1: Listing tables"; aws dynamodb list-tables --query 'TableNames' --output table
echo "Step 2: Table details"
T=$(aws dynamodb list-tables --query 'TableNames[0]' --output text 2>/dev/null)
[ -n "$T" ] && [ "$T" != "None" ] && aws dynamodb describe-table --table-name "$T" --query 'Table.{Name:TableName,Status:TableStatus,Items:ItemCount,Size:TableSizeBytes,Billing:BillingModeSummary.BillingMode}' --output table || echo " No tables"
echo ""; echo "Tutorial complete. Read-only."; rm -rf "$WORK_DIR"
27 changes: 27 additions & 0 deletions tuts/211-iam-list-users/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Iam List Users

A read-only script that queries Iam resources and displays information.

## Running

```bash
bash iam-list-users.sh
```

## What it does

1. Listing IAM users
2. User count"; echo " Total: $(aws iam list-users --query 'Users | length(@)' --output text) users

## Resources created

None — this script is read-only.

## Cost

No cost. This script only reads existing resources.

## Related docs

- [AWS CLI iam reference](https://docs.aws.amazon.com/cli/latest/reference/iam/index.html)

8 changes: 8 additions & 0 deletions tuts/211-iam-list-users/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 211-iam-list-users

## Shell (CLI script)

### 2026-04-14 v1 published
- Type: functional
- Initial version

15 changes: 15 additions & 0 deletions tuts/211-iam-list-users/iam-list-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Iam List Users

## Prerequisites

1. AWS CLI installed and configured (`aws configure`)
2. Appropriate IAM permissions for the AWS services used

## Step 1: Listing IAM users

The script handles this step automatically. See `iam-list-users.sh` for the exact CLI commands.

## Step 2: User count"; echo " Total: $(aws iam list-users --query 'Users | length(@)' --output text) users

The script handles this step automatically. See `iam-list-users.sh` for the exact CLI commands.

6 changes: 6 additions & 0 deletions tuts/211-iam-list-users/iam-list-users.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/tut.log") 2>&1
REGION=${AWS_DEFAULT_REGION:-${AWS_REGION:-$(aws configure get region 2>/dev/null))}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
echo "Step 1: Listing IAM users"; aws iam list-users --query 'Users[].{Name:UserName,Created:CreateDate,PasswordLastUsed:PasswordLastUsed}' --output table
echo "Step 2: User count"; echo " Total: $(aws iam list-users --query 'Users | length(@)' --output text) users"
echo ""; echo "Tutorial complete. Read-only."; rm -rf "$WORK_DIR"
Loading