# Providers

Providers are abstraction layers for interacting with cloud platforms and local infrastructure.
Provisioning supports multiple providers through a unified interface.

## Available Providers

### UpCloud Provider

Production-ready cloud provider for European infrastructure.

**Configuration**:

```nickel
{
  providers.upcloud = {
    username = "your-username",
    password = std.secret "UPCLOUD_PASSWORD",
    default_zone = 'fi-hel1,
    timeout_seconds = 300,
  }
}
```

**Supported zones**:
- `fi-hel1`, `fi-hel2` - Helsinki, Finland
- `de-fra1` - Frankfurt, Germany
- `uk-lon1` - London, UK
- `us-chi1` - Chicago, USA
- `us-sjo1` - San Jose, USA

**Resources**: Servers, networks, storage, firewalls, load balancers

### AWS Provider

Amazon Web Services integration for global cloud infrastructure.

**Configuration**:

```nickel
{
  providers.aws = {
    access_key_id = std.secret "AWS_ACCESS_KEY_ID",
    secret_access_key = std.secret "AWS_SECRET_ACCESS_KEY",
    default_region = "eu-west-1",
  }
}
```

**Resources**: EC2, VPCs, EBS, security groups, RDS, S3

### Local Provider

Local infrastructure for development and testing.

**Configuration**:

```nickel
{
  providers.local = {
    backend = 'libvirt,  # or 'docker, 'podman
    storage_pool = "/var/lib/libvirt/images",
  }
}
```

**Backends**: `libvirt` (KVM/QEMU), `docker`, `podman`

## Multi-Cloud Deployments

Deploy infrastructure across multiple providers:

```nickel
{
  servers = [
    {name = "web-frontend", provider = 'upcloud, zone = "fi-hel1", plan = 'medium},
    {name = "api-backend", provider = 'aws, zone = "eu-west-1a", plan = 't3.large},
  ]
}
```

## Provider Abstraction

Abstract resource definitions work across providers:

```nickel
let server_config = fun name provider => {
  name = name,
  provider = provider,
  plan = 'medium,  # Automatically translated per provider
  storage = [{size_gb = 50, type = 'ssd}],
}
```

Plan translation:

| Abstract | UpCloud | AWS | Local |
| -------- | ------- | --- | ----- |
| small | 1xCPU-1GB | t3.micro | 1 vCPU |
| medium | 2xCPU-4GB | t3.medium | 2 vCPU |
| large | 4xCPU-8GB | t3.large | 4 vCPU |
| xlarge | 8xCPU-16GB | t3.xlarge | 8 vCPU |

## Best Practices

1. **Use abstract plans** - Avoid provider-specific instance types
2. **Encrypt credentials** - Always use encrypted secrets for API keys
3. **Test locally first** - Validate configurations with local provider
4. **Document provider choices** - Comment why specific providers are used
5. **Monitor costs** - Track cloud provider spending

## References

- [Configuration System](configuration-system.md) - Provider configuration
- [Schemas Reference](schemas-reference.md) - Provider schemas
- [Batch Workflows](batch-workflows.md) - Multi-cloud orchestration
