You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A powerful CLI tool for automatically migrating Terraform configurations and state files between different versions of the Cloudflare Terraform Provider.
3
+
A powerful CLI tool for automatically migrating Terraform configurations between different versions of the Cloudflare Terraform Provider.
4
+
5
+
> **Disclaimer:** Please note that v1.0.0-beta.1 is in Beta and we are still testing it for stability.
6
+
4
7
5
8
## Overview
6
9
7
10
`tf-migrate` helps you upgrade your Terraform infrastructure code by automatically transforming:
For comprehensive documentation including architecture, testing, drift exemptions, and development guide, see **[CLAUDE.md](./CLAUDE.md)** - designed to give AI agents (and humans!) complete project context.
82
+
### Pre-built Binaries
17
83
18
-
## Installation
84
+
Download the latest release from the [GitHub Releases](https://github.com/cloudflare/tf-migrate/releases) page. Binaries are available for Linux, macOS, Windows, and FreeBSD on both amd64 and arm64.
19
85
20
86
### Building from Source
21
87
@@ -27,7 +93,7 @@ cd tf-migrate
27
93
# Build the binary
28
94
make
29
95
30
-
# The binary will be available as ./tf-migrate
96
+
# The binary will be available at ./bin/tf-migrate
31
97
```
32
98
33
99
### Requirements
@@ -37,29 +103,6 @@ make
37
103
38
104
## Usage
39
105
40
-
### Authentication
41
-
42
-
Some resource migrations require access to the Cloudflare API to complete the migration successfully. The tool supports two authentication methods:
43
-
44
-
**Option 1: API Token (Recommended)**
45
-
```bash
46
-
export CLOUDFLARE_API_TOKEN="your-api-token"
47
-
```
48
-
49
-
**Option 2: API Key + Email**
50
-
```bash
51
-
export CLOUDFLARE_API_KEY="your-api-key"
52
-
export CLOUDFLARE_EMAIL="your-email@example.com"
53
-
```
54
-
55
-
#### Resources Requiring Authentication
56
-
57
-
The following resources require API credentials for complete migration:
-**Why**: The v4 provider stored network CIDR as the resource ID, but v5 requires the UUID from the API. The migration queries the API to fetch the correct UUID for your tunnel routes.
61
-
-**Without credentials**: The migration will still update resource types and attributes, but you'll need to run `terraform refresh` after migration to update the IDs.
62
-
63
106
### Basic Migration
64
107
65
108
Migrate all Terraform files in the current directory:
|`--config-dir`| Directory containing Terraform configuration files | Current directory |
123
-
|`--state-file`| Path to Terraform state file | None |
124
154
|`--source-version`| Source provider version (e.g., v4) | Required |
125
155
|`--target-version`| Target provider version (e.g., v5) | Required |
126
156
|`--resources`| Comma-separated list of resources to migrate | All resources |
@@ -132,7 +162,6 @@ tf-migrate migrate \
132
162
| Flag | Description | Default |
133
163
|------|-------------|---------|
134
164
|`--output-dir`| Output directory for migrated configuration files | In-place |
135
-
|`--output-state`| Output path for migrated state file | In-place |
136
165
|`--backup`| Create backup of original files before migration | true |
137
166
138
167
### Development Tools
@@ -168,7 +197,7 @@ go test ./... -cover
168
197
169
198
#### Integration Tests
170
199
171
-
Integration tests verify the complete migration workflow using real configuration and state files.
200
+
Integration tests verify the complete migration workflow using real configuration files.
172
201
173
202
```bash
174
203
# Run all v4 to v5 integration tests
@@ -346,6 +375,7 @@ bin/ # Built binaries
346
375
347
376
**CI/CD:**
348
377
349
-
E2E tests run automatically in GitHub Actions on push to `main` or manual workflow dispatch. See `.github/workflows/e2e-tests.yml`.
378
+
-**E2E tests** run automatically in GitHub Actions on push to `main` or manual workflow dispatch. See `.github/workflows/e2e-tests.yml`.
379
+
-**Releases** are automated via GoReleaser. Pushing a `v*` tag triggers `.github/workflows/release.yml`, which cross-compiles binaries and creates a GitHub Release with archives and checksums.
350
380
351
381
**⚠️ Important:** E2E tests create and destroy real Cloudflare resources. Always use a dedicated test account, never production infrastructure.
0 commit comments