feat: Linode Provider v2 migration and backend module
- Documented Linode Terraform Provider v2 migration in ADR-0002 - Created dedicated backend module for state storage - Updated all modules for v2 patterns (cluster→region, pools→pool, tags) - Added firewall outputs and backend outputs - Updated example tfvars files with v2 configurations - Updated AGENTS.md, README.md, and documentation
This commit is contained in:
1 parent
27abc1891b
commit
a5047cb72e
17 files changed
+581
-121
No files matched your search
@@ -0,0 +1,156 @@
|
||||
# ADR-0002: Linode Provider v2 Migration
|
||||
|
||||
## Context
|
||||
|
||||
The Linode Terraform provider released version 2.0 with significant breaking changes that affect our infrastructure configuration. This ADR documents the migration decisions.
|
||||
|
||||
### Provider v1 vs v2 Key Differences
|
||||
|
||||
| Change | Provider v1 | Provider v2 |
|
||||
|--------|-------------|-------------|
|
||||
| Object Storage cluster resource | `linode_object_storage_cluster` (optional) | Removed - cluster specified via `region` |
|
||||
| Object Storage bucket attribute | `cluster` | `region` |
|
||||
| Firewall rules format | List of objects with `cidrs` | Object with `ipv4`/`ipv6` and `action` |
|
||||
| Firewall rule attributes | `direction`, `protocol`, `ports`, `cidrs` | `action`, `protocol`, `ports`, `ipv4`, `ipv6` |
|
||||
| LKE pool attribute | `pools` | `pool` |
|
||||
| LKE tags format | Map with `Environment = value` | Set of `key=value` strings |
|
||||
|
||||
### Existing Infrastructure (v1)
|
||||
|
||||
The original implementation (ADR-0001) used:
|
||||
- `linode_object_storage_cluster` resource for Object Storage cluster
|
||||
- `cluster` attribute on bucket resources
|
||||
- List-based firewall rules with `cidrs`
|
||||
- `pools` block for LKE clusters
|
||||
- Map-based tags
|
||||
|
||||
### Trigger for Migration
|
||||
|
||||
- Linode provider v2 became stable and widely adopted
|
||||
- Newer features and bug fixes only available in v2
|
||||
- Consistency with Linode's evolving API
|
||||
|
||||
## Decision
|
||||
|
||||
We will migrate all infrastructure modules to use **Linode provider v2.0+** (`~> 2.0`).
|
||||
|
||||
### Migration Approach
|
||||
|
||||
1. **Incremental rollout** - Update modules one at a time
|
||||
2. **Backward-compatible variables** - Keep variable names stable, update usage internally
|
||||
3. **Documentation** - Document v2-specific patterns and differences
|
||||
|
||||
### What Stays the Same
|
||||
|
||||
- Module structure (postgres/, storage/, network/, backend/)
|
||||
- Variable names and common patterns
|
||||
- Output structure and naming
|
||||
- Environment separation (staging/production)
|
||||
|
||||
## Status
|
||||
|
||||
**Accepted** - Migration implemented in `feat/01a-linode-terraform-cleanup` branch.
|
||||
|
||||
## Implementation
|
||||
|
||||
### Changes by Module
|
||||
|
||||
#### Backend (`infra/backend/`)
|
||||
|
||||
**Changes:**
|
||||
- Updated provider version constraint to `~> 2.0`
|
||||
- Object Storage bucket configuration updated for v2 API
|
||||
|
||||
#### PostgreSQL (`infra/postgres/`)
|
||||
|
||||
**Changes:**
|
||||
- Provider v2 constraint added to `terraform` block
|
||||
- `cluster` → `region` on `linode_object_storage_bucket`
|
||||
- `pools` → `pool` on `linode_lke_cluster`
|
||||
- Tags converted from map to set of `key=value` strings
|
||||
- Environment variable added to module
|
||||
|
||||
#### Object Storage (`infra/storage/`)
|
||||
|
||||
**Changes:**
|
||||
- Provider v2 constraint added to `terraform` block
|
||||
- Removed `linode_object_storage_cluster` resource
|
||||
- `cluster` → `region` on bucket resources
|
||||
- Removed `depends_on` referencing removed cluster resource
|
||||
- Removed bucket policy configurations (simplified approach)
|
||||
|
||||
#### Networking (`infra/network/`)
|
||||
|
||||
**Changes:**
|
||||
- Provider v2 constraint added to `terraform` block
|
||||
- Firewall rules updated to v2 format:
|
||||
- `cidrs` → `ipv4`/`ipv6`
|
||||
- Added `action` field (`ACCEPT`/`DROP`)
|
||||
- `protocol` now uppercase (`TCP`/`UDP`/`ICMP`)
|
||||
- Environment suffix added to firewall labels
|
||||
- Tags converted to set format
|
||||
- `linode_object_storage_cluster` variable added
|
||||
|
||||
### Variable Changes
|
||||
|
||||
**Added to `infra/variables.tf`:**
|
||||
```hcl
|
||||
variable "object_storage_access_key" {
|
||||
description = "Linode Object Storage access key for backend state storage"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "object_storage_secret_key" {
|
||||
description = "Linode Object Storage secret key for backend state storage"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "linode_object_storage_cluster" {
|
||||
description = "Linode Object Storage cluster for backend state storage"
|
||||
type = string
|
||||
default = "us-east-1"
|
||||
}
|
||||
```
|
||||
|
||||
**Added to module variables:**
|
||||
- `environment` variable added to `postgres/variables.tf` and `storage/variables.tf`
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
|
||||
- **Future-proof** - Using stable, actively maintained provider version
|
||||
- **Simplified architecture** - Removed `linode_object_storage_cluster` resource
|
||||
- **More consistent API** - v2 aligns with Linode's current API conventions
|
||||
- **Better tagging** - Set-based tags provide more flexibility
|
||||
|
||||
### Negative
|
||||
|
||||
- **Breaking changes** - Existing v1 configurations require updates
|
||||
- **Documentation lag** - Need to update docs for v2 patterns
|
||||
- **Learning curve** - Team needs to understand v2 differences
|
||||
|
||||
### Migration Checklist
|
||||
|
||||
- [x] Provider version updated in all modules
|
||||
- [x] Object Storage bucket `cluster` → `region` attribute updated
|
||||
- [x] Firewall rules converted to v2 format
|
||||
- [x] LKE pools renamed to `pool`
|
||||
- [x] Tags converted to set format
|
||||
- [x] Environment variable added to modules
|
||||
- [x] Documentation updated
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **CI/CD integration** - Update workflows to use provider v2
|
||||
2. **State migration** - Plan for state file compatibility
|
||||
3. **Testing** - Verify all modules work with v2 in CI/CD
|
||||
4. **Documentation** - Update user-facing docs with v2 patterns
|
||||
5. **Runbook updates** - Document v2-specific operations
|
||||
|
||||
## References
|
||||
|
||||
- [Linode Terraform Provider v2.0 Release](https://github.com/linode/terraform-provider-linode/releases/tag/v2.0.0)
|
||||
- [Linode Provider Migration Guide](https://registry.terraform.io/providers/linode/linode/latest/docs/guides/version-2-upgrade)
|
||||
- [ADR-0001: Linode Infrastructure with Terraform](./0001-linode-infrastructure-with-terraform.md)
|
||||
Reference in new issue
Block a user