Files
hapi/docs/adr/0002-linode-provider-v2-migration-quick-ref.md
T
Bobby a5047cb72e 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
2026-11-17 23:29:19 -05:00

175 lines
3.3 KiB
Markdown

# Linode Terraform Provider v2 Quick Reference
This guide covers the key differences when working with Linode Provider v2.
## Object Storage
### v1 → v2 Changes
| v1 | v2 |
|---|---|
| `cluster = var.linode_object_storage_cluster` | `region = var.linode_object_storage_cluster` |
| `linode_object_storage_cluster` resource | Removed - cluster is implicit |
### Example
```hcl
# v1
resource "linode_object_storage_bucket" "uploads" {
cluster = var.linode_object_storage_cluster
# ...
}
# v2
resource "linode_object_storage_bucket" "uploads" {
region = var.linode_object_storage_cluster
# ...
}
```
## Firewall Rules
### v1 → v2 Changes
| v1 | v2 |
|---|---|
| `cidrs = ["0.0.0.0/0"]` | `ipv4 = ["0.0.0.0/0"]`, `ipv6 = ["::/0"]` |
| `direction = "inbound"` | `action = "ACCEPT"` or `action = "DROP"` |
| `protocol = "tcp"` | `protocol = "TCP"` (uppercase) |
| `ports = "8000"` | `ports = "8000"` (same) |
### Example
```hcl
# v1
resource "linode_firewall_rule" "api" {
direction = "inbound"
protocol = "tcp"
ports = "8000"
cidrs = ["0.0.0.0/0", "::/0"]
}
# v2
resource "linode_firewall" "hapi" {
inbound {
action = "ACCEPT"
protocol = "TCP"
ports = "8000"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
}
```
## LKE Clusters
### v1 → v2 Changes
| v1 | v2 |
|---|---|
| `pools { ... }` | `pool { ... }` |
| `tags = { Environment = "staging" }` | `tags = toset(["Environment=staging"])` |
### Example
```hcl
# v1
resource "linode_lke_cluster" "postgres" {
pools {
count = 2
type = "g6-standard-4"
}
tags = {
Environment = "staging"
}
}
# v2
resource "linode_lke_cluster" "postgres" {
pool {
count = 2
type = "g6-standard-4"
}
tags = toset([
for k, v in { Environment = "staging" } : "${k}=${v}"
])
}
```
## Tags
### v1 → v2 Changes
- **v1**: Map format `{ key = "value" }`
- **v2**: Set of strings `["key=value"]`
### Conversion
```hcl
# v1
tags = {
Environment = "staging"
Project = "hapi"
}
# v2
tags = toset([
"Environment=staging",
"Project=hapi"
])
# Dynamic conversion
tags = toset([
for k, v in var.tags : "${k}=${v}"
])
```
## Common Patterns
### Environment-Specific Resources
```hcl
# Firewall with environment suffix
resource "linode_firewall" "hapi" {
label = "hapi-firewall-${var.environment}"
}
# Bucket with environment suffix
resource "linode_object_storage_bucket" "uploads" {
label = "hapi-uploads-${var.environment}"
}
```
### Provider Configuration
```hcl
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "~> 2.0"
}
}
}
provider "linode" {
token = var.linode_token
}
```
## Migration Checklist
- [ ] Update provider version constraint to `~> 2.0`
- [ ] Replace `cluster` with `region` on Object Storage buckets
- [ ] Remove `linode_object_storage_cluster` resource if present
- [ ] Convert firewall rules to v2 format
- [ ] Update LKE `pools` → `pool`
- [ ] Convert tags from map to set format
- [ ] Update firewall labels to include environment suffix
## References
- [Linode Provider v2.0 Release](https://github.com/linode/terraform-provider-linode/releases/tag/v2.0.0)
- [Migration Guide](https://registry.terraform.io/providers/linode/linode/latest/docs/guides/version-2-upgrade)
- [ADR-0002](../docs/adr/0002-linode-provider-v2-migration.md)