Skip to content

Commit 57e6152

Browse files
committed
Add integration tutorials (batch 22)
1 parent 49f07d9 commit 57e6152

5 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/amp.log") 2>&1
3+
REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
4+
RANDOM_ID=$(openssl rand -hex 4); WS_ALIAS="tut-ws-${RANDOM_ID}"
5+
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
6+
cleanup() { echo ""; echo "Cleaning up..."; [ -n "$WS_ID" ] && aws amp delete-workspace --workspace-id "$WS_ID" 2>/dev/null && echo " Deleted workspace"; rm -rf "$WORK_DIR"; echo "Done."; }
7+
echo "Step 1: Creating workspace: $WS_ALIAS"
8+
WS_ID=$(aws amp create-workspace --alias "$WS_ALIAS" --query 'workspaceId' --output text)
9+
echo " Workspace ID: $WS_ID"
10+
echo "Step 2: Waiting for workspace..."
11+
for i in $(seq 1 15); do STATUS=$(aws amp describe-workspace --workspace-id "$WS_ID" --query 'workspace.status.statusCode' --output text); echo " $STATUS"; [ "$STATUS" = "ACTIVE" ] && break; sleep 3; done
12+
echo "Step 3: Workspace details"
13+
aws amp describe-workspace --workspace-id "$WS_ID" --query 'workspace.{Id:workspaceId,Alias:alias,Status:status.statusCode,Endpoint:prometheusEndpoint}' --output table
14+
echo "Step 4: Listing workspaces"
15+
aws amp list-workspaces --alias "$WS_ALIAS" --query 'workspaces[].{Id:workspaceId,Alias:alias,Status:status.statusCode}' --output table
16+
echo ""; echo "Tutorial complete."
17+
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup

tuts/139-aws-fis-gs/aws-fis-gs.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/fis.log") 2>&1
3+
REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
4+
RANDOM_ID=$(openssl rand -hex 4); ROLE_NAME="fis-tut-role-${RANDOM_ID}"
5+
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
6+
cleanup() { echo ""; echo "Cleaning up..."; [ -n "$TEMPLATE_ID" ] && aws fis delete-experiment-template --id "$TEMPLATE_ID" > /dev/null 2>&1 && echo " Deleted template"; aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name fis-policy 2>/dev/null; aws iam delete-role --role-name "$ROLE_NAME" 2>/dev/null && echo " Deleted role"; rm -rf "$WORK_DIR"; echo "Done."; }
7+
echo "Step 1: Creating IAM role"
8+
ROLE_ARN=$(aws iam create-role --role-name "$ROLE_NAME" --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"fis.amazonaws.com"},"Action":"sts:AssumeRole"}]}' --query 'Role.Arn' --output text)
9+
aws iam put-role-policy --role-name "$ROLE_NAME" --policy-name fis-policy --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["ec2:DescribeInstances","ec2:StopInstances","ec2:StartInstances"],"Resource":"*"}]}'
10+
echo " Role: $ROLE_ARN"; sleep 10
11+
echo "Step 2: Listing available actions"
12+
aws fis list-actions --query 'actions[:5].{Id:id,Description:description}' --output table
13+
echo "Step 3: Creating experiment template"
14+
TEMPLATE_ID=$(aws fis create-experiment-template --description "Tutorial: stop EC2 instance" --role-arn "$ROLE_ARN" --stop-conditions '[{"source":"none"}]' --actions '{"stopInstances":{"actionId":"aws:ec2:stop-instances","parameters":{"startInstancesAfterDuration":"PT1M"},"targets":{"Instances":"tutorialInstances"}}}' --targets '{"tutorialInstances":{"resourceType":"aws:ec2:instance","selectionMode":"COUNT(1)","resourceTags":{"tutorial":"fis-test"}}}' --query 'experimentTemplate.id' --output text)
15+
echo " Template ID: $TEMPLATE_ID"
16+
echo "Step 4: Describing template"
17+
aws fis get-experiment-template --id "$TEMPLATE_ID" --query 'experimentTemplate.{Id:id,Description:description,Actions:actions|length(@),Targets:targets|length(@)}' --output table
18+
echo "Step 5: Listing templates"
19+
aws fis list-experiment-templates --query 'experimentTemplates[?starts_with(id, `EXT`)].{Id:id,Description:description}' --output table
20+
echo " (Not starting experiment — would require tagged EC2 instances)"
21+
echo ""; echo "Tutorial complete."
22+
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/cr.log") 2>&1
3+
REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text); echo "Region: $REGION"
4+
RANDOM_ID=$(openssl rand -hex 4); COLLAB_NAME="tut-collab-${RANDOM_ID}"
5+
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
6+
cleanup() { echo ""; echo "Cleaning up..."; [ -n "$MEMBERSHIP_ID" ] && aws cleanrooms delete-membership --membership-identifier "$MEMBERSHIP_ID" 2>/dev/null && echo " Deleted membership"; [ -n "$COLLAB_ID" ] && aws cleanrooms delete-collaboration --collaboration-identifier "$COLLAB_ID" 2>/dev/null && echo " Deleted collaboration"; rm -rf "$WORK_DIR"; echo "Done."; }
7+
echo "Step 1: Creating collaboration: $COLLAB_NAME"
8+
RESULT=$(aws cleanrooms create-collaboration --name "$COLLAB_NAME" --description "Tutorial collaboration" --creator-member-abilities '["CAN_QUERY","CAN_RECEIVE_RESULTS"]' --creator-display-name "TutorialCreator" --query-log-status DISABLED --members '[]')
9+
COLLAB_ID=$(echo "$RESULT" | python3 -c "import sys,json;print(json.load(sys.stdin)['collaboration']['id'])")
10+
echo " Collaboration ID: $COLLAB_ID"
11+
echo "Step 2: Creating membership"
12+
MEMBERSHIP_ID=$(aws cleanrooms create-membership --collaboration-identifier "$COLLAB_ID" --query-log-status DISABLED --query 'membership.id' --output text)
13+
echo " Membership ID: $MEMBERSHIP_ID"
14+
echo "Step 3: Describing collaboration"
15+
aws cleanrooms get-collaboration --collaboration-identifier "$COLLAB_ID" --query 'collaboration.{Name:name,Id:id,Status:memberStatus}' --output table
16+
echo "Step 4: Listing collaborations"
17+
aws cleanrooms list-collaborations --query 'collaborationList[?starts_with(name, `tut-`)].{Name:name,Id:id}' --output table
18+
echo ""; echo "Tutorial complete."
19+
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/er.log") 2>&1
3+
REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
4+
RANDOM_ID=$(openssl rand -hex 4); SCHEMA_NAME="tut-schema-${RANDOM_ID}"
5+
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
6+
cleanup() { echo ""; echo "Cleaning up..."; aws entityresolution delete-schema-mapping --schema-name "$SCHEMA_NAME" 2>/dev/null && echo " Deleted schema"; rm -rf "$WORK_DIR"; echo "Done."; }
7+
echo "Step 1: Creating schema mapping: $SCHEMA_NAME"
8+
aws entityresolution create-schema-mapping --schema-name "$SCHEMA_NAME" --mapped-input-fields '[{"fieldName":"id","type":"UNIQUE_ID"},{"fieldName":"name","type":"NAME"},{"fieldName":"email","type":"EMAIL_ADDRESS"}]' --query 'schemaArn' --output text
9+
echo "Step 2: Describing schema"
10+
aws entityresolution get-schema-mapping --schema-name "$SCHEMA_NAME" --query '{Name:schemaName,Fields:mappedInputFields|length(@)}' --output table
11+
echo "Step 3: Listing schemas"
12+
aws entityresolution list-schema-mappings --query 'schemaList[?starts_with(schemaName, `tut-`)].{Name:schemaName}' --output table
13+
echo ""; echo "Tutorial complete."
14+
echo "Do you want to clean up? (y/n): "; read -r CHOICE; [[ "$CHOICE" =~ ^[Yy]$ ]] && cleanup
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/mc.log") 2>&1
3+
REGION=${AWS_DEFAULT_REGION:-$(aws configure get region 2>/dev/null)}; [ -z "$REGION" ] && echo "ERROR: No region" && exit 1; export AWS_DEFAULT_REGION="$REGION"; echo "Region: $REGION"
4+
echo "Step 1: Getting MediaConvert endpoint"
5+
ENDPOINT=$(aws mediaconvert describe-endpoints --query 'Endpoints[0].Url' --output text)
6+
echo " Endpoint: $ENDPOINT"
7+
echo "Step 2: Listing job templates"
8+
aws mediaconvert list-job-templates --endpoint-url "$ENDPOINT" --query 'JobTemplates[:5].{Name:Name,Type:Type}' --output table 2>/dev/null || echo " No custom templates"
9+
echo "Step 3: Listing presets"
10+
aws mediaconvert list-presets --endpoint-url "$ENDPOINT" --list-by SYSTEM --query 'Presets[:5].{Name:Name,Category:Category}' --output table 2>/dev/null || echo " No presets"
11+
echo "Step 4: Listing queues"
12+
aws mediaconvert list-queues --endpoint-url "$ENDPOINT" --query 'Queues[].{Name:Name,Status:Status,Type:Type}' --output table
13+
echo ""; echo "Tutorial complete. No resources created — MediaConvert is job-based."
14+
rm -rf "$WORK_DIR"

0 commit comments

Comments
 (0)