- 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
5.3 KiB
5.3 KiB
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_clusterresource for Object Storage clusterclusterattribute on bucket resources- List-based firewall rules with
cidrs poolsblock 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
- Incremental rollout - Update modules one at a time
- Backward-compatible variables - Keep variable names stable, update usage internally
- 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
terraformblock cluster→regiononlinode_object_storage_bucketpools→poolonlinode_lke_cluster- Tags converted from map to set of
key=valuestrings - Environment variable added to module
Object Storage (infra/storage/)
Changes:
- Provider v2 constraint added to
terraformblock - Removed
linode_object_storage_clusterresource cluster→regionon bucket resources- Removed
depends_onreferencing removed cluster resource - Removed bucket policy configurations (simplified approach)
Networking (infra/network/)
Changes:
- Provider v2 constraint added to
terraformblock - Firewall rules updated to v2 format:
cidrs→ipv4/ipv6- Added
actionfield (ACCEPT/DROP) protocolnow uppercase (TCP/UDP/ICMP)
- Environment suffix added to firewall labels
- Tags converted to set format
linode_object_storage_clustervariable added
Variable Changes
Added to infra/variables.tf:
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:
environmentvariable added topostgres/variables.tfandstorage/variables.tf
Consequences
Positive
- Future-proof - Using stable, actively maintained provider version
- Simplified architecture - Removed
linode_object_storage_clusterresource - 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
- Provider version updated in all modules
- Object Storage bucket
cluster→regionattribute updated - Firewall rules converted to v2 format
- LKE pools renamed to
pool - Tags converted to set format
- Environment variable added to modules
- Documentation updated
Next Steps
- CI/CD integration - Update workflows to use provider v2
- State migration - Plan for state file compatibility
- Testing - Verify all modules work with v2 in CI/CD
- Documentation - Update user-facing docs with v2 patterns
- Runbook updates - Document v2-specific operations