Implementing Cloud Providers
Guide for implementing support for new cloud providers (Azure, GCP, or custom infrastructure).Overview
Adding a new cloud provider requires:- Implementing cloud-provider-api interfaces
- Mapping provider exceptions to CloudProviderException
- Creating Spring Boot autoconfiguration
- Writing tests
Reference Implementations
Before implementing a new provider, review existing implementations:Local Provider (Simple Reference)
Module:cloud-provider-local
The local provider is the simplest complete implementation and serves as an excellent reference:
Advantages as a reference:
- Single module (easier to understand)
- No external dependencies (focus on core interfaces)
- Simple storage (ConcurrentHashMap)
- Clear error handling patterns
- Well-commented code
- Complete test coverage
- Error Handling -
LocalStoreSupport.wrapWithErrorHandling() - Exception Mapping - Java exceptions -> CloudProviderException
- Reactive Wrapping -
Mono.fromCallable()for synchronous operations - LATEST Resolution -
resolveLatestRevision()pattern - Auto-Configuration - Conditional bean creation
AWS Provider (Production Reference)
Module:cloud-provider-aws (4 submodules)
The AWS provider is a production-ready implementation showing advanced patterns:
Advantages as a reference:
- Real-world external service integration (DynamoDB, Secrets Manager)
- Advanced error handling and retries
- Multi-region support
- Metrics publishing (CloudWatch)
- Production-grade testing
- SDK Integration - AWS SDK v2 async client usage
- Retry Logic - Exponential backoff for transient errors
- Connection Pooling - Managing client lifecycle
- Metric Publishing - CloudWatch integration
- Multi-Module Structure - When to split providers
Choosing a Reference
| Aspect | Local Provider | AWS Provider |
|---|---|---|
| Complexity | Simple | Complex |
| Lines of Code | ~1,500 | ~5,000 |
| External Deps | None | AWS SDK, DynamoDB, Secrets Manager |
| Module Structure | Single | 4 submodules |
| Best for Learning | Core patterns | Production patterns |
| Best for Starting | Yes | Use as second reference |
Module Structure
Create a new module following the pattern:Implementing Storage Interfaces
ComponentStore Implementation
SharableStore Implementation
Implementing Configuration Interfaces
ComponentConfigStorage Implementation
Spring Boot Autoconfiguration
Main Configuration Class
Register Autoconfiguration
CreateMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: