@@ -11,6 +11,116 @@ The cloud configuration system follows a pattern similar to Linux kernel refs ma
1111- ** No dependency on cloud CLI tools** for regular users
1212- ** Reduced API calls** to cloud providers
1313
14+ ## Prerequisites for Cloud Providers
15+
16+ ### AWS Prerequisites
17+
18+ The AWS dynamic configuration system uses the official AWS CLI tool and requires proper authentication to access AWS APIs.
19+
20+ #### Requirements
21+
22+ 1 . ** AWS CLI Installation**
23+ ``` bash
24+ # Using pip
25+ pip install awscli
26+
27+ # On Debian/Ubuntu
28+ sudo apt-get install awscli
29+
30+ # On Fedora/RHEL
31+ sudo dnf install aws-cli
32+
33+ # On macOS
34+ brew install awscli
35+ ```
36+
37+ 2 . ** AWS Credentials Configuration**
38+
39+ You need valid AWS credentials configured in one of these ways:
40+
41+ a. ** AWS credentials file** (` ~/.aws/credentials ` ):
42+ ``` ini
43+ [default]
44+ aws_access_key_id = YOUR_ACCESS_KEY
45+ aws_secret_access_key = YOUR_SECRET_KEY
46+ ```
47+
48+ b. ** Environment variables** :
49+ ``` bash
50+ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
51+ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
52+ export AWS_DEFAULT_REGION=us-east-1 # Optional
53+ ```
54+
55+ c. ** IAM Instance Role** (when running on EC2):
56+ - Automatically uses instance metadata service
57+ - No explicit credentials needed
58+
59+ 3 . ** Required AWS Permissions**
60+
61+ The IAM user or role needs the following read-only permissions:
62+ ``` json
63+ {
64+ "Version" : " 2012-10-17" ,
65+ "Statement" : [
66+ {
67+ "Effect" : " Allow" ,
68+ "Action" : [
69+ " ec2:DescribeRegions" ,
70+ " ec2:DescribeAvailabilityZones" ,
71+ " ec2:DescribeInstanceTypes" ,
72+ " ec2:DescribeImages" ,
73+ " pricing:GetProducts"
74+ ],
75+ "Resource" : " *"
76+ },
77+ {
78+ "Effect" : " Allow" ,
79+ "Action" : [
80+ " sts:GetCallerIdentity"
81+ ],
82+ "Resource" : " *"
83+ }
84+ ]
85+ }
86+ ```
87+
88+ #### Verifying AWS Setup
89+
90+ Test your AWS CLI configuration:
91+ ``` bash
92+ # Check AWS CLI is installed
93+ aws --version
94+
95+ # Verify credentials are configured
96+ aws sts get-caller-identity
97+
98+ # Test EC2 access
99+ aws ec2 describe-regions --output table
100+ ```
101+
102+ #### Fallback Behavior
103+
104+ If AWS CLI is not available or credentials are not configured:
105+ - The system automatically falls back to pre-defined static defaults
106+ - Basic instance families (M5, T3, C5, etc.) are still available
107+ - Common regions (us-east-1, eu-west-1, etc.) are provided
108+ - Default GPU AMI options are included
109+ - Users can still use kdevops without AWS API access
110+
111+ ### Lambda Labs Prerequisites
112+
113+ Lambda Labs configuration requires an API key:
114+
115+ 1 . ** Obtain API Key** : Sign up at [ Lambda Labs] ( https://lambdalabs.com ) and generate an API key
116+
117+ 2 . ** Configure API Key** :
118+ ``` bash
119+ export LAMBDA_API_KEY=your_api_key_here
120+ ```
121+
122+ 3 . ** Fallback Behavior** : Without an API key, default GPU instance types are provided
123+
14124## Configuration Generation Flow
15125
16126```
@@ -133,6 +243,48 @@ No cloud CLI tools or API access required - everything loads from committed stat
133243
134244## How It Works
135245
246+ ### Implementation Architecture
247+
248+ The cloud configuration system consists of several key components:
249+
250+ 1 . ** API Wrapper Scripts** (` scripts/aws-cli ` , ` scripts/lambda-cli ` ):
251+ - Provide CLI interfaces to cloud provider APIs
252+ - Handle authentication and error checking
253+ - Format API responses for Kconfig generation
254+
255+ 2 . ** API Libraries** (` scripts/aws_api.py ` , ` scripts/lambdalabs_api.py ` ):
256+ - Core functions for API interactions
257+ - Generate Kconfig syntax from API data
258+ - Provide fallback defaults when APIs unavailable
259+
260+ 3 . ** Generation Orchestrator** (` scripts/generate_cloud_configs.py ` ):
261+ - Coordinates parallel generation across providers
262+ - Provides summary information
263+ - Handles errors gracefully
264+
265+ 4 . ** Makefile Integration** (` scripts/dynamic-cloud-kconfig.Makefile ` ):
266+ - Defines make targets
267+ - Manages file dependencies
268+ - Handles cleanup and updates
269+
270+ ### AWS Implementation Details
271+
272+ The AWS implementation wraps the official AWS CLI tool rather than implementing its own API client:
273+
274+ ``` python
275+ # scripts/aws_api.py
276+ def run_aws_command (command : List[str ], region : str = None ) -> Optional[Any]:
277+ cmd = [" aws" ] + command + [" --output" , " json" ]
278+ # ... executes via subprocess
279+ ```
280+
281+ Key features:
282+ - ** Parallel Generation** : Uses ThreadPoolExecutor to generate instance family files concurrently
283+ - ** GPU Detection** : Automatically identifies GPU instances and enables GPU AMI options
284+ - ** Categorized Instance Types** : Groups instances by use case (general, compute, memory, etc.)
285+ - ** Pricing Integration** : Queries pricing API when available
286+ - ** Smart Defaults** : Falls back to well-tested defaults when API unavailable
287+
136288### Dynamic Configuration Detection
137289
138290kdevops automatically detects whether to use dynamic or static configurations:
@@ -251,18 +403,178 @@ make cloud-config
251403make cloud-update
252404```
253405
406+ ## Troubleshooting
407+
408+ ### AWS Issues
409+
410+ #### "AWS CLI not found" Error
411+ ``` bash
412+ # Verify AWS CLI installation
413+ which aws
414+ aws --version
415+
416+ # Install if missing (see Prerequisites section)
417+ ```
418+
419+ #### "Credentials not configured" Error
420+ ``` bash
421+ # Check current identity
422+ aws sts get-caller-identity
423+
424+ # If fails, configure credentials:
425+ aws configure
426+ # OR
427+ export AWS_ACCESS_KEY_ID=your_key
428+ export AWS_SECRET_ACCESS_KEY=your_secret
429+ ```
430+
431+ #### "Access Denied" Errors
432+ - Verify your IAM user/role has the required permissions (see Prerequisites)
433+ - Check if you're in the correct AWS account
434+ - Ensure your credentials haven't expired
435+
436+ #### Slow Generation Times
437+ - Normal for AWS (6+ minutes due to API pagination)
438+ - Consider using ` make cloud-update ` with pre-generated configs
439+ - Run generation during off-peak hours
440+
441+ #### Missing Instance Types
442+ ``` bash
443+ # Force regeneration
444+ make clean-cloud-config
445+ make cloud-config
446+ make cloud-update
447+ ```
448+
449+ ### General Issues
450+
451+ #### Static Files Not Loading
452+ ``` bash
453+ # Verify static files exist
454+ ls terraform/aws/kconfigs/* .static
455+
456+ # If missing, regenerate:
457+ make cloud-config
458+ make cloud-update
459+ ```
460+
461+ #### Changes Not Reflected in Menuconfig
462+ ``` bash
463+ # Clear Kconfig cache
464+ make mrproper
465+ make menuconfig
466+ ```
467+
468+ #### Debugging API Calls
469+ ``` bash
470+ # Enable debug output
471+ export DEBUG=1
472+ make cloud-config
473+
474+ # Test API directly
475+ scripts/aws-cli --output json regions list
476+ scripts/aws-cli --output json instance-types list --family m5
477+ ```
478+
479+ ## Best Practices
480+
481+ 1 . ** Regular Updates** : Administrators should regenerate configurations monthly or when new instance types are announced
482+
483+ 2 . ** Commit Messages** : Include generation date and tool versions when committing static files:
484+ ``` bash
485+ git commit -m " cloud: update AWS static configurations
486+
487+ Generated with AWS CLI 2.15.0 on 2024-01-15
488+ - Added new G6e instance family
489+ - Updated GPU AMI options
490+ - 127 instance families now available"
491+ ```
492+
493+ 3 . ** Testing** : Always test generated configurations before committing:
494+ ``` bash
495+ make cloud-config
496+ make cloud-update
497+ make menuconfig # Verify options appear correctly
498+ ```
499+
500+ 4 . ** Partial Generation** : For faster testing, generate only specific providers:
501+ ``` bash
502+ make cloud-config-aws # AWS only
503+ make cloud-config-lambdalabs # Lambda Labs only
504+ ```
505+
506+ 5 . ** CI/CD Integration** : Consider automating configuration updates in CI pipelines
507+
508+ ## Advanced Usage
509+
510+ ### Custom AWS Profiles
511+ ``` bash
512+ # Use non-default AWS profile
513+ export AWS_PROFILE=myprofile
514+ make cloud-config
515+ ```
516+
517+ ### Specific Region Generation
518+ ``` bash
519+ # Generate for specific region (affects default selections)
520+ export AWS_DEFAULT_REGION=eu-west-1
521+ make cloud-config
522+ ```
523+
524+ ### Parallel Generation
525+ The system automatically uses parallel processing:
526+ - AWS: Up to 10 concurrent instance family generations
527+ - Reduces total generation time significantly
528+
529+ ## File Reference
530+
531+ ### AWS Files
532+ - ` terraform/aws/kconfigs/Kconfig.compute.{generated,static} ` - Instance families
533+ - ` terraform/aws/kconfigs/Kconfig.location.{generated,static} ` - Regions and zones
534+ - ` terraform/aws/kconfigs/Kconfig.gpu-amis.{generated,static} ` - GPU AMI options
535+ - ` terraform/aws/kconfigs/instance-types/Kconfig.*.{generated,static} ` - Per-family sizes
536+
537+ ### Marker Files
538+ - ` .aws_cloud_config_generated ` - Enables dynamic AWS config
539+ - ` .cloud.initialized ` - General cloud config marker
540+
541+ ### Scripts
542+ - ` scripts/aws-cli ` - AWS CLI wrapper with user-friendly commands
543+ - ` scripts/aws_api.py ` - AWS API library and Kconfig generation
544+ - ` scripts/generate_cloud_configs.py ` - Main orchestrator for all providers
545+ - ` scripts/dynamic-cloud-kconfig.Makefile ` - Make targets and integration
546+
254547## Implementation Details
255548
256- The cloud configuration system is implemented in:
549+ The cloud configuration system is implemented using:
550+
551+ - ** AWS CLI Wrapper** : Uses official AWS CLI via subprocess calls
552+ - ** Parallel Processing** : ThreadPoolExecutor for concurrent API calls
553+ - ** Fallback Defaults** : Pre-defined configurations when API unavailable
554+ - ** Two-tier System** : Generated (dynamic) → Static (committed) files
555+ - ** Kconfig Integration** : Seamless integration with Linux kernel-style configuration
556+
557+ ### Key Design Decisions
558+
559+ 1 . ** Why wrap AWS CLI instead of using boto3?**
560+ - Reduces dependencies (AWS CLI often already installed)
561+ - Leverages AWS's official tool and authentication methods
562+ - Simpler credential management (uses standard AWS config)
563+
564+ 2 . ** Why the two-tier system?**
565+ - Fast loading for regular users (no API calls needed)
566+ - Fresh data when administrators regenerate
567+ - Works offline and in restricted environments
257568
258- - ` scripts/dynamic-cloud-kconfig.Makefile ` - Make targets and build rules
259- - ` scripts/aws_api.py ` - AWS configuration generator
260- - ` scripts/generate_cloud_configs.py ` - Main configuration generator
261- - ` terraform/*/kconfigs/ ` - Provider-specific Kconfig files
569+ 3 . ** Why 6 minutes generation time? **
570+ - AWS API pagination limits (100 items per request)
571+ - Comprehensive data collection (all regions, all instance types)
572+ - Parallel processing already optimized
262573
263574## See Also
264575
265576- [ AWS Instance Types] ( https://aws.amazon.com/ec2/instance-types/ )
266577- [ Azure VM Sizes] ( https://docs.microsoft.com/en-us/azure/virtual-machines/sizes )
267578- [ GCE Machine Types] ( https://cloud.google.com/compute/docs/machine-types )
268579- [ kdevops Terraform Documentation] ( terraform.md )
580+ - [ AWS CLI Documentation] ( https://docs.aws.amazon.com/cli/ )
0 commit comments