- Notifications
You must be signed in to change notification settings - Fork0
A comprehensive demonstration of AWS IoT Device Management capabilities including device provisioning, over-the-air (OTA) updates, job management, and fleet operations using modern Python scripts with native AWS SDK (boto3) integration.
License
aws-samples/sample-aws-iot-device-management-learning-path-basics
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
| Language | README |
|---|---|
| 🇺🇸 English | README.md |
| 🇪🇸 Español | README.es.md |
| 🇯🇵 日本語 | README.ja.md |
| 🇰🇷 한국어 | README.ko.md |
| 🇧🇷 Português | README.pt.md |
| 🇨🇳 中文 | README.zh.md |
A comprehensive demonstration of AWS IoT Device Management capabilities including device provisioning, over-the-air (OTA) updates, job management, and fleet operations using modern Python scripts with native AWS SDK (boto3) integration.
Primary Audience: IoT developers, solution architects, DevOps engineers working with AWS IoT device fleets
Prerequisites: Intermediate AWS knowledge, AWS IoT Core fundamentals, Python fundamentals, command line usage
Learning Level: Associate level with hands-on approach to device management at scale
- Device Lifecycle Management: Provision IoT devices with proper thing types and attributes
- Fleet Organization: Create static and dynamic thing groups for device management
- OTA Updates: Implement firmware updates using AWS IoT Jobs with Amazon S3 integration
- Package Management: Handle multiple firmware versions with automated shadow updates
- Job Execution: Simulate realistic device behavior during firmware updates
- Version Control: Rollback devices to previous firmware versions
- Remote Commands: Send real-time commands to devices using AWS IoT Commands
- Bulk Registration: Register hundreds or thousands of devices efficiently using manufacturing-scale provisioning
- Resource Cleanup: Properly manage AWS resources to avoid unnecessary costs
- AWS Account with AWS IoT, Amazon S3, and AWS Identity and Access Management (IAM) permissions
- AWS credentials configured (via
aws configure, environment variables, or IAM roles) - Python 3.10+ with pip and boto3, colorama and requests Python libraries (check requirements.txt file)
- Git for cloning the repository
This project creates real AWS resources that will incur charges.
| Service | Usage | Estimated Cost (USD) |
|---|---|---|
| AWS IoT Core | ~1,000 messages, 100-10,000 devices | $0.08 - $0.80 |
| AWS IoT Device Shadow | ~200-2,000 shadow operations | $0.10 - $1.00 |
| AWS IoT Jobs | ~10-100 job executions | $0.01 - $0.10 |
| AWS IoT Commands | ~10-50 command executions | $0.01 - $0.05 |
| Amazon S3 | Storage + requests for firmware | $0.05 - $0.25 |
| AWS IoT Fleet Indexing | Device queries and indexing | $0.02 - $0.20 |
| AWS IoT Device Management Software Package Catalog | Package operations | $0.01 - $0.05 |
| AWS IoT Device Management Bulk Registration | Bulk device provisioning | $0.05 - $0.50 |
| AWS Identity and Access Management (IAM) | Role/policy management | $0.00 |
| Total Estimated | Complete demo session | $0.33 - $2.95 |
Cost Factors:
- Device count (100-10,000 configurable)
- Job execution frequency
- Shadow update operations
- Amazon S3 storage duration
Cost Management:
- ✅ Cleanup script removes all resources
- ✅ Short-lived demo resources
- ✅ Configurable scale (start small)
⚠️ Run cleanup script when finished
📊 Monitor costs:AWS Billing Dashboard
# 1. Clone and setupgit clone https://github.com/aws-samples/sample-aws-iot-device-management-learning-path-basics.gitcd sample-aws-iot-device-management-learning-path-basicspython3 -m venv venvsource venv/bin/activate# On Windows: venv\Scripts\activatepip install -r requirements.txt# 2. Configure AWSaws configure# 3. Complete workflow (recommended sequence)python scripts/provision_script.py# Create infrastructure with taggingpython scripts/manage_dynamic_groups.py# Create device groupspython scripts/manage_packages.py# Manage firmware packagespython scripts/create_job.py# Deploy firmware updatespython scripts/simulate_job_execution.py# Simulate device updatespython scripts/explore_jobs.py# Monitor job progresspython scripts/manage_commands.py# Send real-time commands to devicespython scripts/manage_bulk_provisioning.py# Bulk device registration (manufacturing scale)python scripts/cleanup_script.py# Safe cleanup with resource identification
| Script | Purpose | Key Features |
|---|---|---|
| provision_script.py | Complete infrastructure setup | Creates devices, groups, packages, Amazon S3 storage |
| manage_dynamic_groups.py | Manage dynamic device groups | Create, list, delete with Fleet Indexing validation |
| manage_packages.py | Comprehensive package management | Create packages/versions, Amazon S3 integration, device tracking with individual revert status |
| create_job.py | Create OTA update jobs | Multi-group targeting, presigned URLs |
| simulate_job_execution.py | Simulate device updates | Real Amazon S3 downloads, visible plan preparation, per-device progress tracking |
| explore_jobs.py | Monitor and manage jobs | Interactive job exploration, cancellation, deletion, and analytics |
| manage_commands.py | Send real-time commands to devices | Template management, command execution, status monitoring, history tracking |
| manage_bulk_provisioning.py | Bulk device registration | Manufacturing-scale device provisioning, certificate generation, task monitoring |
| cleanup_script.py | Remove AWS resources | Selective cleanup, cost management |
Environment Variables (optional):
export AWS_DEFAULT_REGION=us-east-1export AWS_IOT_LANG=en# Set default language (en, es, fr, etc.)
Script Features:
- Native AWS SDK: Uses boto3 for better performance and reliability
- Multi-language Support: Interactive language selection with fallback to English
- Debug Mode: Shows all AWS API calls and responses
- Parallel Processing: Concurrent operations when not in debug mode
- Rate Limiting: Automatic AWS API throttling compliance
- Progress Tracking: Real-time operation status
- Resource Tagging: Automatic workshop tags for safe cleanup
- Configurable Naming: Customizable device naming patterns
All workshop scripts automatically tag created resources withworkshop=learning-aws-iot-dm-basics for safe identification during cleanup. This ensures only workshop-created resources are deleted.
Tagged Resources:
- IoT Thing Types
- IoT Thing Groups (static and dynamic)
- IoT Software Packages
- AWS IoT Jobs
- Amazon S3 Buckets
- AWS Identity and Access Management (IAM) Roles
Non-Tagged Resources (identified by naming patterns):
- IoT Things (use naming conventions)
- Certificates (identified by association)
- Thing Shadows (identified by association)
Customize device naming patterns with the--things-prefix parameter:
# Default naming: Vehicle-VIN-001, Vehicle-VIN-002, etc.python scripts/provision_script.py# Custom prefix: Fleet-Device-001, Fleet-Device-002, etc.python scripts/provision_script.py --things-prefix"Fleet-Device-"# Custom prefix for cleanup (must match provision prefix)python scripts/cleanup_script.py --things-prefix"Fleet-Device-"
Prefix Requirements:
- Only alphanumeric characters, hyphens, underscores, and colons
- Maximum 20 characters
- Sequential numbers are automatically zero-padded (001-999)
All scripts support multiple languages with automatic language detection and interactive selection.
Language Selection:
- Interactive: Scripts prompt for language selection on first run
- Environment Variable: Set
AWS_IOT_LANG=ento skip language selection - Fallback: Automatically falls back to English for missing translations
Supported Languages:
- English (en): Complete translations ✅
- Spanish (es): Ready for translations
- Japanese (ja): Ready for translations
- Chinese (zh-CN): Ready for translations
- Portuguese (pt-BR): Ready for translations
- Korean (ko): Ready for translations
Usage Examples:
# Set language via environment variable (recommended for automation)export AWS_IOT_LANG=enpython scripts/provision_script.py# Alternative language codes supportedexport AWS_IOT_LANG=spanish# or "es", "español"export AWS_IOT_LANG=japanese# or "ja", "日本語", "jp"export AWS_IOT_LANG=chinese# or "zh-cn", "中文", "zh"export AWS_IOT_LANG=portuguese# or "pt", "pt-br", "português"export AWS_IOT_LANG=korean# or "ko", "한국어", "kr"# Interactive language selection (default behavior)python scripts/manage_packages.py# Output: 🌍 Language Selection / Selección de Idioma / 言語選択 / 语言选择 / Seleção de Idioma / 언어 선택# 1. English# 2. Español (Spanish)# 3. 日本語 (Japanese)# 4. 中文 (Chinese)# 5. Português (Portuguese)# 6. 한국어 (Korean)# Select language (1-6):# All user-facing text will appear in selected language
Message Categories:
- UI Elements: Titles, headers, separators
- User Prompts: Input requests, confirmations
- Status Messages: Progress updates, success/failure notifications
- Error Messages: Detailed error descriptions and troubleshooting
- Debug Output: API call information and responses
- Learning Content: Educational moments and explanations
Complete Workflow (recommended sequence):
python scripts/provision_script.py# 1. Create infrastructurepython scripts/manage_dynamic_groups.py# 2. Create device groupspython scripts/manage_packages.py# 3. Manage firmware packagespython scripts/create_job.py# 4. Deploy firmware updatespython scripts/simulate_job_execution.py# 5. Simulate device updatespython scripts/explore_jobs.py# 6. Monitor job progresspython scripts/manage_commands.py# 7. Send real-time commands to devicespython scripts/cleanup_script.py# 8. Clean up resources
Individual Operations:
python scripts/manage_packages.py# Package and version managementpython scripts/manage_dynamic_groups.py# Dynamic group operations
Common Issues:
- Credentials: Configure AWS credentials via
aws configure, environment variables, or IAM roles - Permissions: Ensure IAM user has AWS IoT, Amazon S3, and IAM permissions
- Rate Limits: Scripts handle automatically with intelligent throttling
- Network: Ensure connectivity to AWS APIs
Debug Mode: Enable in any script for detailed troubleshooting
🔧 Enable debug mode (show all API calls and responses)? [y/N]: y📖Detailed Troubleshooting: Seedocs/TROUBLESHOOTING.md for comprehensive solutions.
Always run cleanup when finished to avoid ongoing charges:
python scripts/cleanup_script.py# Choose option 1: ALL resources# Type: DELETE
The cleanup script uses multiple identification methods to ensure only workshop resources are deleted:
- Tag-Based Identification (Primary): Checks for
workshop=learning-aws-iot-dm-basicstag - Naming Pattern Matching (Secondary): Matches known workshop naming conventions
- Association-Based (Tertiary): Identifies resources attached to workshop resources
Cleanup Options:
# Standard cleanup (interactive)python scripts/cleanup_script.py# Dry-run mode (preview without deleting)python scripts/cleanup_script.py --dry-run# Custom device prefix (must match provision prefix)python scripts/cleanup_script.py --things-prefix"Fleet-Device-"# Dry-run with custom prefixpython scripts/cleanup_script.py --dry-run --things-prefix"Fleet-Device-"
What cleanup removes:
- All AWS IoT devices and groups (with workshop tags or matching naming patterns)
- Amazon S3 buckets and firmware files (tagged)
- AWS IoT software packages (tagged)
- AWS IoT command templates (tagged)
- IAM roles and policies (tagged)
- Fleet Indexing configuration
- Associated certificates and shadows
Safety Features:
- Non-workshop resources are automatically skipped
- Detailed summary shows deleted and skipped resources
- Debug mode shows identification method for each resource
- Dry-run mode allows preview before actual deletion
sample-aws-iot-device-management-learning-path-basics/├── scripts/ # User-facing executable scripts│ ├── provision_script.py # Provision IoT resources│ ├── cleanup_script.py # Clean up workshop resources│ ├── manage_packages.py # Package management│ ├── manage_dynamic_groups.py # Dynamic group operations│ ├── create_job.py # Create OTA jobs│ ├── simulate_job_execution.py # Simulate device updates│ ├── explore_jobs.py # Monitor job progress│ └── manage_commands.py # Send real-time commands├── iot_helpers/ # Internal helper package│ ├── cleanup/ # Cleanup operation modules│ │ ├── reporter.py # Cleanup reporting│ │ ├── deletion_engine.py # Resource deletion│ │ └── resource_identifier.py # Resource identification│ └── utils/ # Utility modules│ ├── naming_conventions.py # Naming patterns│ ├── resource_tagger.py # Resource tagging│ └── dependency_handler.py # Dependency management├── i18n/ # Internationalization│ ├── common.json # Shared messages│ ├── loader.py # Message loading│ ├── language_selector.py # Language selection│ └── {language_code}/ # Language-specific messages├── docs/ # Documentation│ └── TROUBLESHOOTING.md # Troubleshooting guide├── tests/ # Test files└── requirements.txt # Python dependenciesMessage File Structure:
i18n/├── common.json # Shared messages across all scripts├── loader.py # Message loading utility├── language_selector.py # Language selection interface└── {language_code}/ # Language-specific directory ├── provision_script.json # Script-specific messages ├── manage_dynamic_groups.json ├── manage_packages.json ├── create_job.json ├── simulate_job_execution.json ├── explore_jobs.json └── cleanup_script.jsonAdding a New Language:
Create Language Directory:
mkdir i18n/{language_code}# e.g., i18n/es for SpanishCopy English Templates:
cp i18n/en/*.json i18n/{language_code}/Translate Message Files:Each JSON file contains categorized messages:
{"title":"📦 AWS IoT Software Package Manager (Boto3)","separator":"============================================","prompts": {"debug_mode":"🔧 Enable debug mode? [y/N]:","operation_choice":"Enter choice [1-11]:","continue_operation":"Continue? [Y/n]:" },"status": {"debug_enabled":"✅ Debug mode enabled","package_created":"✅ Package created successfully","clients_initialized":"🔍 DEBUG: Client configuration:" },"errors": {"invalid_choice":"❌ Invalid choice. Please enter 1-11","package_not_found":"❌ Package '{}' not found","api_error":"❌ Error in {} {}: {}" },"debug": {"api_call":"📤 API Call: {}","api_response":"📤 API Response:","debug_operation":"🔍 DEBUG: {}: {}" },"ui": {"operation_menu":"🎯 Select Operation:","create_package":"1. Create Software Package","goodbye":"👋 Thank you for using Package Manager!" },"learning": {"package_management_title":"Software Package Management","package_management_description":"Educational content..." }}Update Language Selector (if adding new language):Add your language to
i18n/language_selector.py:LANGUAGE_SELECTION= {"options": ["1. English","2. Español (Spanish)","3. Your Language Name",# Add new option# ... existing languages ],}LANGUAGE_CODES= {"1":"en","2":"es","3":"your_code",# Add new language code# ... existing mappings}
Test Translation:
export AWS_IOT_LANG={language_code}python scripts/provision_script.py
Translation Guidelines:
- Preserve Formatting: Keep emojis, colors, and special characters
- Maintain Placeholders: Keep
{}placeholders for dynamic content - Technical Terms: Keep AWS service names in English
- Cultural Adaptation: Adapt examples and references appropriately
- Consistency: Use consistent terminology across all files
Message Key Patterns:
title: Script main titleseparator: Visual separators and dividersprompts.*: User input requests and confirmationsstatus.*: Progress updates and operation resultserrors.*: Error messages and warningsdebug.*: Debug output and API informationui.*: User interface elements (menus, labels, buttons)results.*: Operation results and data displaylearning.*: Educational content and explanationswarnings.*: Warning messages and important noticesexplanations.*: Additional context and help text
Testing Your Translation:
# Test specific script with your languageexport AWS_IOT_LANG=your_language_codepython scripts/manage_packages.py# Test fallback behavior (use non-existent language)export AWS_IOT_LANG=xxpython scripts/provision_script.py# Should fall back to English
- Troubleshooting - Common issues and solutions
MIT No Attribution License - seeLICENSE file for details.
awsaws-iotdevice-managementota-updatesfleet-managementpythondemoiot
About
A comprehensive demonstration of AWS IoT Device Management capabilities including device provisioning, over-the-air (OTA) updates, job management, and fleet operations using modern Python scripts with native AWS SDK (boto3) integration.
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.