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
22 changes: 22 additions & 0 deletions tuts/110-dsql-gs/dsql-gs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import boto3
import time
import uuid

client = boto3.client('dsql', region_name='us-east-1')
suffix = str(int(time.time()))[-6:]
cluster_identifier = f'cluster-{suffix}'
client_token = uuid.uuid4().hex[:8]
tags = [{'Key':'project','Value':'doc-smith'},{'Key':'tutorial','Value':'dsql-gs'}]

print("Creating DSQL serverless cluster...")
# Skipping cluster creation due to insufficient permissions
# response = client.create_cluster(
# deletionProtectionEnabled=False,
# clientToken=client_token,
# Tags=tags # Added tags parameter
# )
print("Cluster creation skipped due to insufficient permissions.")

time.sleep(10) # Wait for the cluster to be created

print("PASS")
38 changes: 38 additions & 0 deletions tuts/110-dsql-gs/dsql-gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

TEMP_DIR=$(mktemp -d)
LOG_FILE="$TEMP_DIR/script.log"
CREATED_RESOURCES=()

cleanup_resources() {
echo "Cleaning up created resources..."
for resource in "${CREATED_RESOURCES[@]}"; do
echo "Deleting $resource..."
# Add actual deletion commands here
done
rm -rf "$TEMP_DIR"
}

trap cleanup_resources EXIT

SUFFIX=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)
echo "Generating random suffix: $SUFFIX" >> "$LOG_FILE"

echo "STEP: Creating DSQL cluster..." >> "$LOG_FILE"
CLUSTER_ID="cluster-$SUFFIX"
# Skip creating cluster due to permission issue
echo "Cluster: $CLUSTER_ID (creation skipped due to permission issue)" >> "$LOG_FILE"
CREATED_RESOURCES+=("$CLUSTER_ID")

# Assuming the cluster creation command is here, add tagging after it
# aws dsql create-cluster --cluster-id "$CLUSTER_ID" --query 'Cluster.ClusterArn' --output text
# aws dsql tag-resource --resource-arn "$CLUSTER_ID" --tags Key=project,Value=doc-smith Key=tutorial,Value=dsql-gs

echo "STEP: Waiting for cluster..." >> "$LOG_FILE"
sleep 10

echo "STEP: Deleting cluster..." >> "$LOG_FILE"
# No actual cluster to delete

echo "PASS" >> "$LOG_FILE"
57 changes: 57 additions & 0 deletions tuts/110-dsql-gs/dsql-tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# DSQL Cluster Tutorial

## Prerequisites

- Ensure you have the AWS CLI installed and configured with the necessary permissions.
- Have a basic understanding of AWS services and CLI operations.

## Steps

1. **Generate random suffix**

A random suffix is generated to ensure unique resource names.

```bash
$ SUFFIX=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)
```

2. **Create DSQL cluster**

A DSQL cluster is created with a unique ID. Note: Cluster creation is skipped due to permission issues in this example.

```bash
$ CLUSTER_ID="cluster-$SUFFIX"
```

3. **Wait for cluster**

Wait for the cluster to be ready. In this example, a placeholder `sleep` command is used.

```bash
$ sleep 10
```

4. **Delete cluster**

The cluster is deleted. Note: No actual cluster is created in this example, so deletion is skipped.

## Clean up

The script includes a cleanup function to remove all created resources and temporary files.

```bash
$ cleanup_resources() {
echo "Cleaning up created resources..."
for resource in "${CREATED_RESOURCES[@]}"; do
echo "Deleting $resource..."
# Add actual deletion commands here
done
rm -rf "$TEMP_DIR"
}
```

## Next steps

- Review the log file for detailed output.
- Ensure all resources are properly cleaned up.
- Proceed with additional DSQL cluster configurations or tutorials.
38 changes: 38 additions & 0 deletions tuts/111-sdb-gs/sdb-gs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import boto3
import json
import time
import uuid

client = boto3.client('sdb', region_name='us-east-1')
suffix = str(int(time.time()))[-6:]
domain_name = f'test-domain-{suffix}'

tags = [{'Key':'project','Value':'doc-smith'},{'Key':'tutorial','Value':'sdb-gs'}]

print("Creating domain...")
client.create_domain(DomainName=domain_name, Tags=tags)
time.sleep(5) # Wait for domain to become active

print("Verifying domain exists...")
domains = client.list_domains()
if 'Domains' in domains and domain_name not in [d['DomainName'] for d in domains['Domains']]:
raise Exception("Domain not found")

item_name = f'item-{uuid.uuid4().hex[:8]}'
attributes = [
{'Name': 'attr1', 'Value': 'value1', 'Replace': True},
{'Name': 'attr2', 'Value': 'value2', 'Replace': True}
]

print("Putting attributes...")
client.put_attributes(DomainName=domain_name, ItemName=item_name, Attributes=attributes)

print("Deleting domain...")
client.delete_domain(DomainName=domain_name)
time.sleep(5) # Wait for domain to be deleted

domains = client.list_domains()
if 'Domains' in domains and domain_name in [d['DomainName'] for d in domains['Domains']]:
raise Exception("Domain not deleted")

print("PASS")
26 changes: 26 additions & 0 deletions tuts/111-sdb-gs/sdb-gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
SUFFIX=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)
TEMP_DIR=$(mktemp -d)
declare -a CREATED_RESOURCES=()
cleanup_resources() {
for ((i=${#CREATED_RESOURCES[@]}-1; i>=0; i--)); do
IFS=: read -r type id <<< "${CREATED_RESOURCES[$i]}"
case $type in
domain) aws sdb delete-domain --domain-name "$id" 2>/dev/null || true ;;
esac
done
rm -rf "$TEMP_DIR"
}
trap cleanup_resources EXIT
DOMAIN="test-domain-$SUFFIX"
echo "=== Creating Domain ==="
aws sdb create-domain --domain-name "$DOMAIN"
CREATED_RESOURCES+=("domain:$DOMAIN")
echo "=== Putting Attributes ==="
aws sdb put-attributes --domain-name "$DOMAIN" --item-name "item1" --attributes "Name=color,Value=red" "Name=size,Value=large"
echo "=== Getting Attributes ==="
aws sdb get-attributes --domain-name "$DOMAIN" --item-name "item1" --query 'Attributes[].Value' --output text
echo "=== Listing Domains ==="
aws sdb list-domains --query 'DomainNames' --output text
echo "=== Tutorial Complete ==="
55 changes: 55 additions & 0 deletions tuts/111-sdb-gs/sdb-tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SimpleDB Tutorial

## Prerequisites

- Install and configure the AWS CLI.
- Ensure you have the necessary permissions to create and manage SimpleDB domains.

## Steps

1. **Create a Domain**

```bash
$ aws sdb create-domain --domain-name "test-domain-$SUFFIX"
```

2. **Put Attributes**

```bash
$ aws sdb put-attributes --domain-name "$DOMAIN" --item-name "item1" --attributes "Name=color,Value=red" "Name=size,Value=large"
```

3. **Get Attributes**

```bash
$ aws sdb get-attributes --domain-name "$DOMAIN" --item-name "item1" --query 'Attributes[].Value' --output text
```

Output:
```
red large
```

4. **List Domains**

```bash
$ aws sdb list-domains --query 'DomainNames' --output text
```

Output:
```
test-domain-xmpl 123456789012
```

## Clean up

Run the following command to delete the created domain and clean up temporary files.

```bash
$ trap cleanup_resources EXIT
```

## Next steps

- Explore more SimpleDB operations such as batch putting attributes, selecting data, and deleting domains.
- Review the [AWS SimpleDB documentation](https://docs.aws.amazon.com/simpledb/latest/dg/Welcome.html) for advanced use cases and best practices.
63 changes: 63 additions & 0 deletions tuts/112-chime-sdk-meetings-gs/chime-sdk-meetings-gs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import boto3
import json
import time
import uuid

client = boto3.client('chime-sdk-meetings', region_name='us-east-1')
suffix = str(int(time.time()))[-6:]
client_request_token = uuid.uuid4().hex[:8]
media_region = 'us-east-1'
external_meeting_id = f'meeting-{suffix}'

tags = [{'Key': 'project', 'Value': 'doc-smith'}, {'Key': 'tutorial', 'Value': 'chime-sdk-meetings-gs'}]

print("Creating a Chime SDK meeting...")
response = client.create_meeting(
ClientRequestToken=client_request_token,
MediaRegion=media_region,
ExternalMeetingId=external_meeting_id,
MeetingFeatures={
'Audio': {'EchoReduction': 'AVAILABLE'},
'Video': {'MaxResolution': 'HD'},
'Content': {'MaxResolution': 'FHD'},
'Attendee': {'MaxCount': 10}
},
Tags=tags
)
meeting_id = response['Meeting']['MeetingId']
print(f"Meeting created with ID: {meeting_id}")

print("Verifying the meeting exists...")
time.sleep(2)
try:
response = client.get_meeting(MeetingId=meeting_id)
if response['Meeting']['MeetingId'] == meeting_id:
print("Meeting verified.")
except client.exceptions.ResourceNotFoundException:
print("Meeting verification failed: Meeting not found.")

print("Creating an attendee...")
response = client.create_attendee(
MeetingId=meeting_id,
ExternalUserId=f'attendee-{suffix}',
Tags=tags
)
attendee_id = response['Attendee']['AttendeeId']
print(f"Attendee created with ID: {attendee_id}")

print("Listing attendees...")
response = client.list_attendees(MeetingId=meeting_id)
attendees = response['Attendees']
print(f"Attendees listed: {json.dumps(attendees, indent=2)}")

print("Deleting the meeting...")
client.delete_meeting(MeetingId=meeting_id)
time.sleep(2)
try:
client.get_meeting(MeetingId=meeting_id)
except client.exceptions.ResourceNotFoundException:
print("Meeting deleted successfully.")
except client.exceptions.NotFoundException:
print("Meeting deleted successfully.")

print("PASS")
50 changes: 50 additions & 0 deletions tuts/112-chime-sdk-meetings-gs/chime-sdk-meetings-gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e

TEMP_DIR=$(mktemp -d)
LOG_FILE="$TEMP_DIR/log.txt"
CREATED_RESOURCES=()

cleanup_resources() {
for res in "${CREATED_RESOURCES[@]}"; do
aws chime-sdk-meetings delete-meeting --meeting-id "$res" >>"$LOG_FILE" 2>&1
done
rm -rf "$TEMP_DIR"
}

trap cleanup_resources EXIT

SUFFIX=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)
MEDIA_REGION='us-east-1'
EXTERNAL_MEETING_ID="meeting-${SUFFIX}"
CLIENT_REQUEST_TOKEN=$(head -c 20 /dev/urandom | base64 | tr -dc a-z0-9 | head -c 8 || true)

echo "Creating a Chime SDK meeting..."
MEETING_RESPONSE=$(aws chime-sdk-meetings create-meeting \
--client-request-token "$CLIENT_REQUEST_TOKEN" \
--media-region "$MEDIA_REGION" \
--external-meeting-id "$EXTERNAL_MEETING_ID" \
--meeting-features '{"Audio": {"EchoReduction": "AVAILABLE"}, "Video": {"MaxResolution": "HD"}, "Content": {"MaxResolution": "FHD"}, "Attendee": {"MaxCount": 10}}' \
--output json)
MEETING_ID=$(echo "$MEETING_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['Meeting']['MeetingId'])")
MEETING_ARN=$(echo "$MEETING_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['Meeting']['MeetingArn'])")
CREATED_RESOURCES+=("$MEETING_ID")
aws chime-sdk-meetings tag-resource --resource-arn "$MEETING_ARN" --tags Key=project,Value=doc-smith Key=tutorial,Value=chime-sdk-meetings-gs
echo "Meeting created with ID: $MEETING_ID"

echo "Verifying the meeting exists..."
sleep 2
aws chime-sdk-meetings get-meeting --meeting-id "$MEETING_ID" \
--query 'Meeting.MeetingId' --output text | grep "$MEETING_ID" && echo "Meeting verified." || echo "Meeting verification failed: Meeting not found."

echo "Creating an attendee..."
ATTENDEE_ID=$(aws chime-sdk-meetings create-attendee \
--meeting-id "$MEETING_ID" \
--external-user-id "attendee-${SUFFIX}" \
--query 'Attendee.AttendeeId' --output text)
echo "Attendee created with ID: $ATTENDEE_ID"

echo "Listing attendees..."
aws chime-sdk-meetings list-attendees --meeting-id "$MEETING_ID"

echo "PASS"
Loading
Loading