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
38 changes: 38 additions & 0 deletions tuts/153-dynamodb-streams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Dynamodb Streams

An AWS CLI tutorial that demonstrates Dynamodb operations.

## Running

```bash
bash dynamodb-streams.sh
```

To auto-run with cleanup:

```bash
echo 'y' | bash dynamodb-streams.sh
```

## What it does

1. Creating table with streams enabled
2. Writing items to trigger stream events
3. Reading stream records

## Resources created

- Table
- Item

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 dynamodb reference](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html)
- [AWS CLI dynamodbstreams reference](https://docs.aws.amazon.com/cli/latest/reference/dynamodbstreams/index.html)

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

## Shell (CLI script)

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

23 changes: 23 additions & 0 deletions tuts/153-dynamodb-streams/dynamodb-streams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dynamodb Streams

## Prerequisites

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

## Step 1: Creating table with streams enabled

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

## Step 2: Writing items to trigger stream events

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

## Step 3: Reading stream records

The script handles this step automatically. See `dynamodb-streams.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.

22 changes: 22 additions & 0 deletions tuts/153-dynamodb-streams/dynamodb-streams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/ddb-streams.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); TABLE="tut-stream-${RANDOM_ID}"
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
cleanup() { echo ""; echo "Cleaning up..."; aws dynamodb delete-table --table-name "$TABLE" > /dev/null 2>&1 && echo " Deleted table"; rm -rf "$WORK_DIR"; echo "Done."; }
echo "Step 1: Creating table with streams enabled"
aws dynamodb create-table --table-name "$TABLE" --key-schema AttributeName=pk,KeyType=HASH --attribute-definitions AttributeName=pk,AttributeType=S --billing-mode PAY_PER_REQUEST --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES --query 'TableDescription.{Table:TableName,Stream:LatestStreamArn}' --output table
aws dynamodb wait table-exists --table-name "$TABLE"
STREAM_ARN=$(aws dynamodb describe-table --table-name "$TABLE" --query 'Table.LatestStreamArn' --output text)
echo "Step 2: Writing items to trigger stream events"
aws dynamodb put-item --table-name "$TABLE" --item '{"pk":{"S":"user-1"},"name":{"S":"Alice"},"age":{"N":"30"}}' 2>/dev/null
aws dynamodb put-item --table-name "$TABLE" --item '{"pk":{"S":"user-2"},"name":{"S":"Bob"},"age":{"N":"25"}}' 2>/dev/null
aws dynamodb update-item --table-name "$TABLE" --key '{"pk":{"S":"user-1"}}' --update-expression "SET age = :a" --expression-attribute-values '{":a":{"N":"31"}}' 2>/dev/null
aws dynamodb delete-item --table-name "$TABLE" --key '{"pk":{"S":"user-2"}}' 2>/dev/null
echo " 4 operations: 2 puts, 1 update, 1 delete"
echo "Step 3: Reading stream records"
SHARD_ID=$(aws dynamodbstreams describe-stream --stream-arn "$STREAM_ARN" --query 'StreamDescription.Shards[0].ShardId' --output text)
ITERATOR=$(aws dynamodbstreams get-shard-iterator --stream-arn "$STREAM_ARN" --shard-id "$SHARD_ID" --shard-iterator-type TRIM_HORIZON --query 'ShardIterator' --output text)
aws dynamodbstreams get-records --shard-iterator "$ITERATOR" --query 'Records[].{Event:eventName,Keys:dynamodb.Keys}' --output table
echo ""; echo "Tutorial complete."
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
39 changes: 39 additions & 0 deletions tuts/162-dynamodb-continuous-backups/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Dynamodb Global Tables

An AWS CLI tutorial that demonstrates Dynamodb operations.

## Running

```bash
bash dynamodb-global-tables.sh
```

To auto-run with cleanup:

```bash
echo 'y' | bash dynamodb-global-tables.sh
```

## What it does

1. Creating table
2. Enabling point-in-time recovery
3. Describing continuous backups
4. Writing and reading items
5. Table details

## Resources created

- Table
- Item

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 dynamodb reference](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html)

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

## Shell (CLI script)

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

31 changes: 31 additions & 0 deletions tuts/162-dynamodb-continuous-backups/dynamodb-global-tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Dynamodb Global Tables

## Prerequisites

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

## Step 1: Creating table

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

## Step 2: Enabling point-in-time recovery

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

## Step 3: Describing continuous backups

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

## Step 4: Writing and reading items

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

## Step 5: Table details

The script handles this step automatically. See `dynamodb-global-tables.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.

21 changes: 21 additions & 0 deletions tuts/162-dynamodb-continuous-backups/dynamodb-global-tables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/ddb-global.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); TABLE="tut-global-${RANDOM_ID}"
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
cleanup() { echo ""; echo "Cleaning up..."; aws dynamodb delete-table --table-name "$TABLE" > /dev/null 2>&1 && echo " Deleted table"; rm -rf "$WORK_DIR"; echo "Done."; }
echo "Step 1: Creating table"
aws dynamodb create-table --table-name "$TABLE" --key-schema AttributeName=pk,KeyType=HASH --attribute-definitions AttributeName=pk,AttributeType=S --billing-mode PAY_PER_REQUEST --query 'TableDescription.TableName' --output text > /dev/null
aws dynamodb wait table-exists --table-name "$TABLE"
echo "Step 2: Enabling point-in-time recovery"
aws dynamodb update-continuous-backups --table-name "$TABLE" --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true > /dev/null
echo " PITR enabled"
echo "Step 3: Describing continuous backups"
aws dynamodb describe-continuous-backups --table-name "$TABLE" --query 'ContinuousBackupsDescription.{Status:ContinuousBackupsStatus,PITR:PointInTimeRecoveryDescription.PointInTimeRecoveryStatus}' --output table
echo "Step 4: Writing and reading items"
aws dynamodb put-item --table-name "$TABLE" --item '{"pk":{"S":"item-1"},"data":{"S":"Hello"}}' 2>/dev/null
aws dynamodb get-item --table-name "$TABLE" --key '{"pk":{"S":"item-1"}}' --query 'Item.{pk:pk.S,data:data.S}' --output table
echo "Step 5: Table details"
aws dynamodb describe-table --table-name "$TABLE" --query 'Table.{Name:TableName,Status:TableStatus,Items:ItemCount,Billing:BillingModeSummary.BillingMode}' --output table
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/164-rds-snapshots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Rds Snapshots

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

## Running

```bash
bash rds-snapshots.sh
```

## What it does

1. Listing RDS instances
2. Listing automated snapshots
3. Listing manual snapshots
4. Listing cluster snapshots

## Resources created

None — this script is read-only.

## Cost

No cost. This script only reads existing resources.

## Related docs

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

8 changes: 8 additions & 0 deletions tuts/164-rds-snapshots/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision History: 164-rds-snapshots

## Shell (CLI script)

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

23 changes: 23 additions & 0 deletions tuts/164-rds-snapshots/rds-snapshots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Rds Snapshots

## Prerequisites

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

## Step 1: Listing RDS instances

The script handles this step automatically. See `rds-snapshots.sh` for the exact CLI commands.

## Step 2: Listing automated snapshots

The script handles this step automatically. See `rds-snapshots.sh` for the exact CLI commands.

## Step 3: Listing manual snapshots

The script handles this step automatically. See `rds-snapshots.sh` for the exact CLI commands.

## Step 4: Listing cluster snapshots

The script handles this step automatically. See `rds-snapshots.sh` for the exact CLI commands.

13 changes: 13 additions & 0 deletions tuts/164-rds-snapshots/rds-snapshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/rds-snap.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 RDS instances"
aws rds describe-db-instances --query 'DBInstances[:5].{Id:DBInstanceIdentifier,Engine:Engine,Status:DBInstanceStatus,Class:DBInstanceClass}' --output table 2>/dev/null || echo " No RDS instances"
echo "Step 2: Listing automated snapshots"
aws rds describe-db-snapshots --snapshot-type automated --query 'DBSnapshots[:5].{Id:DBSnapshotIdentifier,Instance:DBInstanceIdentifier,Status:Status,Engine:Engine}' --output table 2>/dev/null || echo " No automated snapshots"
echo "Step 3: Listing manual snapshots"
aws rds describe-db-snapshots --snapshot-type manual --query 'DBSnapshots[:5].{Id:DBSnapshotIdentifier,Status:Status,Size:AllocatedStorage}' --output table 2>/dev/null || echo " No manual snapshots"
echo "Step 4: Listing cluster snapshots"
aws rds describe-db-cluster-snapshots --query 'DBClusterSnapshots[:3].{Id:DBClusterSnapshotIdentifier,Cluster:DBClusterIdentifier,Status:Status}' --output table 2>/dev/null || echo " No cluster snapshots"
echo ""; echo "Tutorial complete. No resources created — read-only."
rm -rf "$WORK_DIR"
39 changes: 39 additions & 0 deletions tuts/168-dynamodb-queries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Dynamodb Queries

An AWS CLI tutorial that demonstrates Dynamodb operations.

## Running

```bash
bash dynamodb-queries.sh
```

To auto-run with cleanup:

```bash
echo 'y' | bash dynamodb-queries.sh
```

## What it does

1. Creating table with GSI
2. Writing items
3. Query by partition key
4. Query GSI (active users)
5. Scan with filter

## Resources created

- Table
- Item

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 dynamodb reference](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html)

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

## Shell (CLI script)

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

31 changes: 31 additions & 0 deletions tuts/168-dynamodb-queries/dynamodb-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Dynamodb Queries

## Prerequisites

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

## Step 1: Creating table with GSI

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

## Step 2: Writing items

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

## Step 3: Query by partition key

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

## Step 4: Query GSI (active users)

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

## Step 5: Scan with filter

The script handles this step automatically. See `dynamodb-queries.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.

23 changes: 23 additions & 0 deletions tuts/168-dynamodb-queries/dynamodb-queries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/ddb-query.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); TABLE="tut-query-${RANDOM_ID}"
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
cleanup() { echo ""; echo "Cleaning up..."; aws dynamodb delete-table --table-name "$TABLE" > /dev/null 2>&1 && echo " Deleted table"; rm -rf "$WORK_DIR"; echo "Done."; }
echo "Step 1: Creating table with GSI"
aws dynamodb create-table --table-name "$TABLE" --key-schema AttributeName=pk,KeyType=HASH AttributeName=sk,KeyType=RANGE --attribute-definitions AttributeName=pk,AttributeType=S AttributeName=sk,AttributeType=S AttributeName=status,AttributeType=S --billing-mode PAY_PER_REQUEST --global-secondary-indexes '[{"IndexName":"status-index","KeySchema":[{"AttributeName":"status","KeyType":"HASH"},{"AttributeName":"sk","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"}}]' > /dev/null
aws dynamodb wait table-exists --table-name "$TABLE"
echo "Step 2: Writing items"
for i in 1 2 3 4 5; do
STATUS=$( [ $((i % 2)) -eq 0 ] && echo "active" || echo "inactive" )
aws dynamodb put-item --table-name "$TABLE" --item "{\"pk\":{\"S\":\"user-$i\"},\"sk\":{\"S\":\"profile\"},\"name\":{\"S\":\"User $i\"},\"status\":{\"S\":\"$STATUS\"}}" 2>/dev/null
done
echo " Wrote 5 items"
echo "Step 3: Query by partition key"
aws dynamodb query --table-name "$TABLE" --key-condition-expression "pk = :pk" --expression-attribute-values '{":pk":{"S":"user-1"}}' --query 'Items[].{pk:pk.S,name:name.S,status:status.S}' --output table
echo "Step 4: Query GSI (active users)"
aws dynamodb query --table-name "$TABLE" --index-name status-index --key-condition-expression "#s = :s" --expression-attribute-names '{"#s":"status"}' --expression-attribute-values '{":s":{"S":"active"}}' --query 'Items[].{pk:pk.S,name:name.S}' --output table
echo "Step 5: Scan with filter"
aws dynamodb scan --table-name "$TABLE" --filter-expression "#s = :s" --expression-attribute-names '{"#s":"status"}' --expression-attribute-values '{":s":{"S":"inactive"}}' --query '{Count:Count,Items:Items[].{pk:pk.S,name:name.S}}' --output table
echo ""; echo "Tutorial complete."
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
Loading
Loading