Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
053b58e
Non-interactive: 42 tutorials from pipeline + 5 fixed locally
mwunderl Apr 28, 2026
11790c5
Add 2 more passing non-interactive scripts (012, 015)
mwunderl Apr 28, 2026
027878c
Fix 019-lambda: regex pattern for test event validation
mwunderl Apr 28, 2026
859585d
Fix 6 test failures: 3 still-interactive, 1 syntax, 1 local-outside-f…
mwunderl Apr 28, 2026
91f22a7
Fix 081-mediaconnect: 8 more local-outside-function. Fix 001-lightsai…
mwunderl Apr 28, 2026
6753d60
Revert 033-ses non-interactive changes — requires real email verifica…
mwunderl Apr 28, 2026
5b89af0
Fix 081-mediaconnect: local-outside-fn, jq path, ARN regex — passes l…
mwunderl Apr 28, 2026
2b6809f
Fix 5 scripts + linter: 032 zip test, 066 cognito (4 bugs), 074 textr…
mwunderl Apr 28, 2026
0445bc8
Fix 053-config (shared bucket + read), 082-polly (SSML quotes + CLI f…
mwunderl Apr 28, 2026
4194ace
Fix 043-mq (AWS_REGION fallback), 015-vpc-peering (log path), 028-sag…
mwunderl Apr 28, 2026
b8c0694
Remove 010-cloudmap and 033-ses from non-interactive PR
mwunderl Apr 28, 2026
af71a94
Fix 043-mq (SIGPIPE, password chars, EFS storage), 058-elb (local out…
mwunderl Apr 29, 2026
0103b52
Fix 039-redshift (ra3.xlplus, remove logging), 047-firewall (replace-…
mwunderl Apr 29, 2026
7f4f243
Fix 047-firewall: try replace-route, fall back to create-route — pass…
mwunderl Apr 29, 2026
c120571
059-datazone: document IAM Identity Center prereq for environment pro…
mwunderl Apr 29, 2026
65f362f
Fix 024-glue: remove unnecessary CLI v2 requirement — all commands wo…
mwunderl Apr 29, 2026
609dbe6
Fix 040+042 Q Business: use configured region, fix jq status path — b…
mwunderl Apr 29, 2026
2823523
Fix 018-ecs-ec2: heredoc 'EOF' → EOF for variable expansion. Add 000-…
mwunderl Apr 29, 2026
d562d7d
Document 035-workspaces (needs AD user) and 059-datazone (needs IC+Da…
mwunderl Apr 29, 2026
fa9b058
Remove 035-workspaces and 059-datazone from non-interactive PR (manua…
mwunderl Apr 29, 2026
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
1 change: 1 addition & 0 deletions .doc_gen/validation.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
allow_list:
- "bPxRfiCYEXAMPLEKEY/wJalrXUtnFEMI/K7MDENG"
- "role/AmazonEC2ContainerServiceforEC2Role"
- "========================================"
sample_files:
- "README.md"
25 changes: 25 additions & 0 deletions BRANCH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# feature/non-interactive

## What's in this branch
42 tutorial scripts made non-interactive by the DocBash pipeline (run_group: non-interactive-20260427-1821).
Plus 5 scripts fixed locally before the pipeline run (013-ec2, 019-lambda, 033-ses, 035-workspaces, 047-firewall).

All `read -p` and `read -r` user prompts replaced with auto-answers:
- Cleanup confirmations → y
- Press Enter → removed or sleep
- Runtime/config selection → first option
- Email/name/domain → generated values
- VPC/subnet selection → first option or auto-detect

## Status
- 44/70 tutorials passing (42 pipeline + 2 retry)
- 5 fixed locally (on main, included here)
- 21 remaining failures — all environment quota limits (VpcLimitExceeded, AddressLimitExceeded)

## Before publishing
- [ ] Rerun the 21 failures after VPC cleanup completes
- [ ] Verify no `read` prompts remain in passing scripts (spot check)
- [ ] Update REVISION-HISTORY.md for each modified tutorial

## After publishing
- [ ] Rebase feature/resource-tagging off this branch (tagging needs non-interactive as prereq)
39 changes: 39 additions & 0 deletions tuts/000-prereqs-directory/cfn-prereqs-directory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Prereq: Simple AD directory for WorkSpaces tutorials. Uses default VPC.'

Parameters:
DirectoryName:
Type: String
Default: corp.example.com
DirectorySize:
Type: String
Default: Small
AllowedValues: [Small, Large]
VpcId:
Type: AWS::EC2::VPC::Id
Description: VPC for the directory (use default VPC)
SubnetId1:
Type: AWS::EC2::Subnet::Id
Description: First subnet (must be in a different AZ from SubnetId2)
SubnetId2:
Type: AWS::EC2::Subnet::Id
Description: Second subnet (must be in a different AZ from SubnetId1)

Resources:
Directory:
Type: AWS::DirectoryService::SimpleAD
Properties:
Name: !Ref DirectoryName
Password: 'TutorialPass123!'
Size: !Ref DirectorySize
VpcSettings:
VpcId: !Ref VpcId
SubnetIds:
- !Ref SubnetId1
- !Ref SubnetId2

Outputs:
DirectoryId:
Value: !Ref Directory
Export:
Name: !Sub '${AWS::StackName}-DirectoryId'
4 changes: 4 additions & 0 deletions tuts/001-lightsail-gs/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
- Type: functional
- Remove SDK content from CFN branch (belongs on SDK branches)


### 2026-04-27 v-ni1 non-interactive
- Type: functional
- Made script fully non-interactive for automated testing
81 changes: 41 additions & 40 deletions tuts/001-lightsail-gs/lightsail-gs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# Amazon Lightsail Getting Started CLI Script
# This script demonstrates how to create and manage Lightsail resources using the AWS CLI

set -euo pipefail

# Set AWS region
export AWS_REGION="us-west-2"
export AWS_REGION="${AWS_REGION:-us-west-2}"
echo "Using AWS region: $AWS_REGION"

# Set up logging
Expand All @@ -16,9 +17,9 @@ echo "Starting Lightsail Getting Started script at $(date)"

# Error handling function
handle_error() {
echo "ERROR: $1"
echo "ERROR: $1" >&2
echo "Attempting to clean up resources..."
cleanup_resources
cleanup_resources || true
exit 1
}

Expand Down Expand Up @@ -58,35 +59,34 @@ cleanup_resources() {
case "$type" in
"instance_snapshot")
echo "Deleting instance snapshot: $name"
aws lightsail delete-instance-snapshot --instance-snapshot-name "$name" --region $AWS_REGION
aws lightsail delete-instance-snapshot --instance-snapshot-name "$name" --region "$AWS_REGION" 2>/dev/null || true
;;
"disk_snapshot")
echo "Deleting disk snapshot: $name"
aws lightsail delete-disk-snapshot --disk-snapshot-name "$name" --region $AWS_REGION
aws lightsail delete-disk-snapshot --disk-snapshot-name "$name" --region "$AWS_REGION" 2>/dev/null || true
;;
"disk")
echo "Detaching disk: $name"
aws lightsail detach-disk --disk-name "$name" --region $AWS_REGION
sleep 10 # Wait for detach to complete
aws lightsail detach-disk --disk-name "$name" --region "$AWS_REGION" 2>/dev/null || true
sleep 10
echo "Deleting disk: $name"
aws lightsail delete-disk --disk-name "$name" --region $AWS_REGION
aws lightsail delete-disk --disk-name "$name" --region "$AWS_REGION" 2>/dev/null || true
;;
"instance")
echo "Deleting instance: $name"
# Check instance state before attempting to delete
INSTANCE_STATE=$(aws lightsail get-instance-state --instance-name "$name" --region $AWS_REGION --query 'state.name' --output text 2>/dev/null)
INSTANCE_STATE=$(aws lightsail get-instance-state --instance-name "$name" --region "$AWS_REGION" --query 'state.name' --output text 2>/dev/null || echo "unknown")
if [ "$INSTANCE_STATE" == "pending" ]; then
echo "Instance is in pending state. Waiting for it to be ready before deleting..."
MAX_WAIT=30
WAITED=0
while [ "$INSTANCE_STATE" == "pending" ] && [ $WAITED -lt $MAX_WAIT ]; do
sleep 10
WAITED=$((WAITED+1))
INSTANCE_STATE=$(aws lightsail get-instance-state --instance-name "$name" --region $AWS_REGION --query 'state.name' --output text 2>/dev/null)
INSTANCE_STATE=$(aws lightsail get-instance-state --instance-name "$name" --region "$AWS_REGION" --query 'state.name' --output text 2>/dev/null || echo "unknown")
echo "Instance state: $INSTANCE_STATE"
done
fi
aws lightsail delete-instance --instance-name "$name" --region $AWS_REGION
aws lightsail delete-instance --instance-name "$name" --region "$AWS_REGION" 2>/dev/null || true
;;
esac
done
Expand All @@ -102,11 +102,11 @@ check_status "Failed to verify AWS CLI configuration"
# Step 2: Get available blueprints and bundles
echo "Step 2: Getting available blueprints and bundles"
echo "Available blueprints (showing first 5):"
aws lightsail get-blueprints --region $AWS_REGION --query 'blueprints[0:5].[blueprintId,name]' --output table
aws lightsail get-blueprints --region "$AWS_REGION" --query 'blueprints[0:5].[blueprintId,name]' --output table
check_status "Failed to get blueprints"

echo "Available bundles (showing first 5):"
aws lightsail get-bundles --region $AWS_REGION --query 'bundles[0:5].[bundleId,name,price]' --output table
aws lightsail get-bundles --region "$AWS_REGION" --query 'bundles[0:5].[bundleId,name,price]' --output table
check_status "Failed to get bundles"

# Get available regions and availability zones
Expand All @@ -122,17 +122,16 @@ aws lightsail create-instances \
--availability-zone "$AVAILABILITY_ZONE" \
--blueprint-id amazon_linux_2023 \
--bundle-id nano_3_0 \
--region $AWS_REGION
--region "$AWS_REGION"
check_status "Failed to create Lightsail instance"
track_resource "instance" "$INSTANCE_NAME"

# Wait for the instance to be in a running state
echo "Waiting for instance to be in running state..."
# Wait for the instance to be ready (polling approach)
MAX_ATTEMPTS=30
ATTEMPTS=0
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
STATUS=$(aws lightsail get-instance-state --instance-name "$INSTANCE_NAME" --region $AWS_REGION --query 'state.name' --output text)
STATUS=$(aws lightsail get-instance-state --instance-name "$INSTANCE_NAME" --region "$AWS_REGION" --query 'state.name' --output text 2>/dev/null || echo "unknown")
if [ "$STATUS" == "running" ]; then
echo "Instance is now running"
break
Expand All @@ -148,15 +147,26 @@ fi

# Get instance details
echo "Getting instance details"
INSTANCE_IP=$(aws lightsail get-instance --instance-name "$INSTANCE_NAME" --region $AWS_REGION --query 'instance.publicIpAddress' --output text)
INSTANCE_IP=$(aws lightsail get-instance --instance-name "$INSTANCE_NAME" --region "$AWS_REGION" --query 'instance.publicIpAddress' --output text)
check_status "Failed to get instance IP address"
echo "Instance IP address: $INSTANCE_IP"

# Validate IP address format
if ! [[ "$INSTANCE_IP" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
handle_error "Invalid IP address format: $INSTANCE_IP"
fi

# Step 4: Download the default key pair
echo "Step 4: Downloading default key pair"
KEY_FILE="lightsail_key_${RANDOM_ID}.pem"
aws lightsail download-default-key-pair --region $AWS_REGION --output text > "$KEY_FILE"
umask 077
aws lightsail download-default-key-pair --region "$AWS_REGION" --output text > "$KEY_FILE"
check_status "Failed to download key pair"

if [ ! -f "$KEY_FILE" ] || [ ! -s "$KEY_FILE" ]; then
handle_error "Key pair file was not created or is empty"
fi

chmod 400 "$KEY_FILE"
check_status "Failed to set permissions on key pair"
echo "Key pair downloaded to $KEY_FILE"
Expand All @@ -170,16 +180,16 @@ aws lightsail create-disk \
--disk-name "$DISK_NAME" \
--availability-zone "$AVAILABILITY_ZONE" \
--size-in-gb 8 \
--region $AWS_REGION
--region "$AWS_REGION"
check_status "Failed to create disk"
track_resource "disk" "$DISK_NAME"

# FIX: Wait for the disk to be available using polling instead of fixed sleep
# Wait for the disk to be available using polling
echo "Waiting for disk to be available..."
MAX_ATTEMPTS=30
ATTEMPTS=0
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
DISK_STATE=$(aws lightsail get-disk --disk-name "$DISK_NAME" --region $AWS_REGION --query 'disk.state' --output text 2>/dev/null)
DISK_STATE=$(aws lightsail get-disk --disk-name "$DISK_NAME" --region "$AWS_REGION" --query 'disk.state' --output text 2>/dev/null || echo "unknown")
if [ "$DISK_STATE" == "available" ]; then
echo "Disk is now available"
break
Expand All @@ -199,7 +209,7 @@ aws lightsail attach-disk \
--disk-name "$DISK_NAME" \
--instance-name "$INSTANCE_NAME" \
--disk-path /dev/xvdf \
--region $AWS_REGION
--region "$AWS_REGION"
check_status "Failed to attach disk to instance"

echo "Disk attached. To format and mount the disk, connect to your instance and run:"
Expand All @@ -213,17 +223,17 @@ echo "Step 6: Creating snapshot of the instance: $SNAPSHOT_NAME"
aws lightsail create-instance-snapshot \
--instance-name "$INSTANCE_NAME" \
--instance-snapshot-name "$SNAPSHOT_NAME" \
--region $AWS_REGION
--region "$AWS_REGION"
check_status "Failed to create instance snapshot"
track_resource "instance_snapshot" "$SNAPSHOT_NAME"

# FIX: Wait for the snapshot to complete using polling instead of fixed sleep
# Wait for the snapshot to complete using polling
echo "Waiting for snapshot to complete... (this may take several minutes)"
MAX_ATTEMPTS=60 # Increased timeout for snapshot creation
MAX_ATTEMPTS=60
ATTEMPTS=0
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
SNAPSHOT_STATE=$(aws lightsail get-instance-snapshot --instance-snapshot-name "$SNAPSHOT_NAME" --region $AWS_REGION --query 'instanceSnapshot.state' --output text 2>/dev/null)
if [ "$SNAPSHOT_STATE" == "completed" ]; then
SNAPSHOT_STATE=$(aws lightsail get-instance-snapshot --instance-snapshot-name "$SNAPSHOT_NAME" --region "$AWS_REGION" --query 'instanceSnapshot.state' --output text 2>/dev/null || echo "unknown")
if [ "$SNAPSHOT_STATE" == "available" ]; then
echo "Snapshot creation completed"
break
fi
Expand All @@ -244,16 +254,7 @@ for resource in "${CREATED_RESOURCES[@]}"; do
echo " $resource"
done

read -p "Do you want to clean up these resources? (y/n): " CLEANUP_CONFIRM
if [[ "$CLEANUP_CONFIRM" == "y" || "$CLEANUP_CONFIRM" == "Y" ]]; then
cleanup_resources
else
echo "Resources will not be cleaned up. You can manually delete them later."
echo "To clean up manually, use the following commands:"
echo "aws lightsail delete-instance-snapshot --instance-snapshot-name $SNAPSHOT_NAME --region $AWS_REGION"
echo "aws lightsail detach-disk --disk-name $DISK_NAME --region $AWS_REGION"
echo "aws lightsail delete-disk --disk-name $DISK_NAME --region $AWS_REGION"
echo "aws lightsail delete-instance --instance-name $INSTANCE_NAME --region $AWS_REGION"
fi
echo "Cleaning up these resources automatically..."
cleanup_resources

echo "Script completed at $(date)"
echo "Script completed at $(date)"
4 changes: 4 additions & 0 deletions tuts/003-s3-gettingstarted/REVISION-HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
- Type: functional
- Script checks for prereq bucket stack before creating its own S3 bucket
- Skips bucket deletion if using shared bucket

### 2026-04-27 v-ni1 non-interactive
- Type: functional
- Made script fully non-interactive for automated testing
Loading
Loading