Skip to main content

Implementing Cloud Providers

Guide for implementing support for new cloud providers (Azure, GCP, or custom infrastructure).

Overview

Adding a new cloud provider requires:
  1. Implementing cloud-provider-api interfaces
  2. Mapping provider exceptions to CloudProviderException
  3. Creating Spring Boot autoconfiguration
  4. 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
Key classes to study:
Example: Simple ComponentStore:
Study these patterns:
  1. Error Handling - LocalStoreSupport.wrapWithErrorHandling()
  2. Exception Mapping - Java exceptions -> CloudProviderException
  3. Reactive Wrapping - Mono.fromCallable() for synchronous operations
  4. LATEST Resolution - resolveLatestRevision() pattern
  5. 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
Module structure:
Study these patterns:
  1. SDK Integration - AWS SDK v2 async client usage
  2. Retry Logic - Exponential backoff for transient errors
  3. Connection Pooling - Managing client lifecycle
  4. Metric Publishing - CloudWatch integration
  5. Multi-Module Structure - When to split providers
View AWS provider documentation

Choosing a Reference

Recommendation: Start with the local provider to understand core patterns, then review AWS provider for production considerations.

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

Create META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:

Configuration Properties

Testing

Unit Tests

Integration Tests

Use Test Containers or Azure emulator for integration tests.

Example: Azure Provider Structure

See Also