tf-project 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tf_project-0.2.3 → tf_project-0.3.0}/PKG-INFO +76 -70
- {tf_project-0.2.3 → tf_project-0.3.0}/README.md +61 -50
- tf_project-0.3.0/pyproject.toml +70 -0
- tf_project-0.3.0/rust/.config/nextest.toml +6 -0
- tf_project-0.3.0/rust/Cargo.lock +693 -0
- tf_project-0.3.0/rust/Cargo.toml +55 -0
- tf_project-0.3.0/rust/clippy.toml +9 -0
- tf_project-0.3.0/rust/deny.toml +21 -0
- tf_project-0.3.0/rust/rust-toolchain.toml +3 -0
- tf_project-0.3.0/rust/rustfmt.toml +2 -0
- tf_project-0.3.0/rust/src/banner.rs +247 -0
- tf_project-0.3.0/rust/src/bin/tfp.rs +5 -0
- tf_project-0.3.0/rust/src/cli.rs +1671 -0
- tf_project-0.3.0/rust/src/commands.rs +1129 -0
- tf_project-0.3.0/rust/src/config.rs +469 -0
- tf_project-0.3.0/rust/src/lib.rs +288 -0
- tf_project-0.3.0/rust/src/lock.rs +445 -0
- tf_project-0.3.0/rust/src/main.rs +5 -0
- tf_project-0.3.0/rust/src/models.rs +383 -0
- tf_project-0.3.0/rust/src/secrets.rs +142 -0
- tf_project-0.3.0/rust/src/self_commands.rs +592 -0
- tf_project-0.3.0/rust/src/slots.rs +366 -0
- tf_project-0.3.0/rust/src/state.rs +168 -0
- tf_project-0.3.0/rust/src/terraform.rs +210 -0
- tf_project-0.3.0/rust/src/text.rs +49 -0
- tf_project-0.3.0/rust/tests/cli.rs +100 -0
- tf_project-0.3.0/rust/tests/fixtures/last_invocation.json +9 -0
- tf_project-0.3.0/rust/tests/fixtures/my_state.json +16 -0
- tf_project-0.3.0/rust/tests/fixtures/tfplan_meta.json +10 -0
- tf_project-0.2.3/CHANGELOG.md +0 -258
- tf_project-0.2.3/pyproject.toml +0 -248
- tf_project-0.2.3/src/tf_project/__init__.py +0 -18
- tf_project-0.2.3/src/tf_project/__main__.py +0 -4
- tf_project-0.2.3/src/tf_project/__version__.py +0 -20
- tf_project-0.2.3/src/tf_project/banner.py +0 -164
- tf_project-0.2.3/src/tf_project/cli.py +0 -899
- tf_project-0.2.3/src/tf_project/commands.py +0 -911
- tf_project-0.2.3/src/tf_project/config.py +0 -294
- tf_project-0.2.3/src/tf_project/lock.py +0 -281
- tf_project-0.2.3/src/tf_project/migrate.py +0 -142
- tf_project-0.2.3/src/tf_project/models.py +0 -201
- tf_project-0.2.3/src/tf_project/preflight.py +0 -65
- tf_project-0.2.3/src/tf_project/py.typed +0 -0
- tf_project-0.2.3/src/tf_project/secrets.py +0 -78
- tf_project-0.2.3/src/tf_project/self_commands.py +0 -724
- tf_project-0.2.3/src/tf_project/slots.py +0 -256
- tf_project-0.2.3/src/tf_project/state.py +0 -135
- tf_project-0.2.3/src/tf_project/terraform.py +0 -176
- {tf_project-0.2.3 → tf_project-0.3.0}/LICENSE +0 -0
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tf-project
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Terraform / OpenTofu wrapper with named per-tfvars slots, cached `.terraform/`, 1Password secret injection, and apply-safety guards.
|
|
5
|
-
Keywords: terraform,opentofu,tofu,infrastructure-as-code,iac,devops,cli,wrapper,tfvars,multi-environment,workspaces,1password,op-cli,secrets,sops,azurerm,s3-backend,terraform-state,sigstore
|
|
6
|
-
Author-Email: Ilja Orlovs <ilja@release.art>
|
|
7
|
-
Maintainer-Email: Ilja Orlovs <ilja@release.art>
|
|
8
|
-
License-Expression: MIT
|
|
3
|
+
Version: 0.3.0
|
|
9
4
|
Classifier: Development Status :: 4 - Beta
|
|
10
5
|
Classifier: Environment :: Console
|
|
11
6
|
Classifier: Intended Audience :: Developers
|
|
12
7
|
Classifier: Intended Audience :: System Administrators
|
|
13
|
-
Classifier: Operating System :: POSIX
|
|
14
8
|
Classifier: Operating System :: MacOS
|
|
15
|
-
Classifier:
|
|
16
|
-
Classifier:
|
|
17
|
-
Classifier: Programming Language ::
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Rust
|
|
20
12
|
Classifier: Topic :: Software Development :: Build Tools
|
|
21
13
|
Classifier: Topic :: System :: Installation/Setup
|
|
22
14
|
Classifier: Topic :: System :: Systems Administration
|
|
23
15
|
Classifier: Topic :: Utilities
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Summary: Terraform / OpenTofu wrapper with named per-tfvars slots, cached `.terraform/`, 1Password secret injection, and apply-safety guards.
|
|
18
|
+
Keywords: terraform,opentofu,tofu,infrastructure-as-code,iac,devops,cli,wrapper,tfvars,multi-environment,workspaces,1password,op-cli,secrets,azurerm,s3-backend,terraform-state
|
|
19
|
+
Author-email: Ilja Orlovs <ilja@release.art>
|
|
20
|
+
Maintainer-email: Ilja Orlovs <ilja@release.art>
|
|
21
|
+
License-Expression: MIT
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
28
23
|
Project-URL: Changelog, https://github.com/release-art/tf-project/blob/main/CHANGELOG.md
|
|
24
|
+
Project-URL: Documentation, https://github.com/release-art/tf-project#readme
|
|
25
|
+
Project-URL: Homepage, https://github.com/release-art/tf-project
|
|
29
26
|
Project-URL: Issues, https://github.com/release-art/tf-project/issues
|
|
30
27
|
Project-URL: Releases, https://github.com/release-art/tf-project/releases
|
|
31
|
-
|
|
32
|
-
Requires-Dist: typer>=0.26.0
|
|
33
|
-
Requires-Dist: pydantic>=2.13.4
|
|
34
|
-
Description-Content-Type: text/markdown
|
|
28
|
+
Project-URL: Repository, https://github.com/release-art/tf-project
|
|
35
29
|
|
|
36
30
|
# tf-project
|
|
37
31
|
|
|
38
32
|
[](https://pypi.org/project/tf-project/)
|
|
39
|
-
[](https://pypi.org/project/tf-project/)
|
|
40
33
|
[](https://github.com/release-art/tf-project/blob/main/LICENSE)
|
|
41
34
|
|
|
42
35
|
A thin, opinionated **Terraform / OpenTofu** wrapper for multi-environment
|
|
@@ -56,9 +49,9 @@ time you switch, this tool replaces that ritual with `tfp use dev`.
|
|
|
56
49
|
swapping between them is instant when both are warm.
|
|
57
50
|
- **Shared provider cache** via `TF_PLUGIN_CACHE_DIR`. Providers download
|
|
58
51
|
once and link into every slot's `.terraform/providers/`.
|
|
59
|
-
- **Versioned,
|
|
52
|
+
- **Versioned, strictly validated state files.** Every persisted JSON carries
|
|
60
53
|
`schema_version`; unknown fields fail loudly (except in user-authored
|
|
61
|
-
banners, where they are tolerated and
|
|
54
|
+
banners, where they are tolerated and reported by `tfp self banner check`).
|
|
62
55
|
- Pluggable tfvars preprocessing - defaults to [1Password's `op inject`][op]
|
|
63
56
|
so you can keep `op://...` references in tfvars committed to git.
|
|
64
57
|
|
|
@@ -67,10 +60,19 @@ time you switch, this tool replaces that ritual with `tfp use dev`.
|
|
|
67
60
|
## Install
|
|
68
61
|
|
|
69
62
|
```sh
|
|
70
|
-
pip install tf-project
|
|
63
|
+
pip install tf-project # or: uv tool install tf-project / pipx install tf-project
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-
The CLI is exposed as both `tf-project` and the shorter alias `tfp`.
|
|
66
|
+
The CLI is exposed as both `tf-project` and the shorter alias `tfp`. It is a
|
|
67
|
+
single native program; the PyPI wheels (Linux x86_64 / arm64, macOS arm64,
|
|
68
|
+
Windows x86_64) contain nothing else.
|
|
69
|
+
|
|
70
|
+
To install without Python, download
|
|
71
|
+
`tf-project-<version>-<target>.tar.gz` (`.zip` for Windows) from a
|
|
72
|
+
[GitHub Release][releases] and put `tfp` / `tf-project` on your `PATH`. Every
|
|
73
|
+
release file is signed with [Sigstore][sigstore].
|
|
74
|
+
|
|
75
|
+
[releases]: https://github.com/release-art/tf-project/releases
|
|
74
76
|
|
|
75
77
|
## Configure
|
|
76
78
|
|
|
@@ -92,7 +94,8 @@ tfvars_dir = "tfvars" # scanned for slots; used by `tfp fmt`
|
|
|
92
94
|
tmp_dir = "tmp" # slot dirs + plugin cache land here
|
|
93
95
|
state_key_prefix = "terraform/azure/" # remote backend key prefix
|
|
94
96
|
|
|
95
|
-
# Optional. Defaults to `
|
|
97
|
+
# Optional. Defaults to `terraform` as found on PATH. A bare name (`tofu`) is
|
|
98
|
+
# looked up on PATH when run; a path is taken relative to the project root.
|
|
96
99
|
# terraform_binary = "bin/terraform-1.7.5"
|
|
97
100
|
|
|
98
101
|
# Optional. Defaults to `<tmp_dir>/plugin-cache`. Set to "" to disable.
|
|
@@ -139,14 +142,14 @@ Banner fields:
|
|
|
139
142
|
| `env` | JSON object of `string → string` env vars passed to terraform when running against this slot. |
|
|
140
143
|
| `backend_config` | JSON object of extra `-backend-config k=v` pairs. Wins over the config-level `[tf_project.backend_config]` table. |
|
|
141
144
|
|
|
142
|
-
Unknown banner fields are tolerated (forward-compatible across tfp versions)
|
|
143
|
-
|
|
145
|
+
Unknown banner fields are tolerated (forward-compatible across tfp versions);
|
|
146
|
+
`tfp self banner check` names them, so a typo doesn't disappear silently.
|
|
144
147
|
|
|
145
148
|
## Usage
|
|
146
149
|
|
|
147
150
|
```sh
|
|
148
151
|
tfp use dev # switch to slot "dev" (no init if already warm)
|
|
149
|
-
tfp use tfvars/prod.tfvars #
|
|
152
|
+
tfp use tfvars/prod.tfvars # a tfvars path works too
|
|
150
153
|
tfp init # re-bind the active slot's backend from its banner
|
|
151
154
|
# (run after editing a banner's state_key/backend_config)
|
|
152
155
|
tfp ls # list slots; active marked with `*`
|
|
@@ -170,7 +173,7 @@ tfp state replace-provider hashicorp/aws registry.acme.local/aws
|
|
|
170
173
|
tfp state identities # 1.10+
|
|
171
174
|
tfp import aws_s3_bucket.foo my-bucket
|
|
172
175
|
# forwards the decrypted tfvars + saved env
|
|
173
|
-
tfp status #
|
|
176
|
+
tfp status # summary of the active slot
|
|
174
177
|
tfp last # last terraform invocation for the active slot
|
|
175
178
|
```
|
|
176
179
|
|
|
@@ -192,10 +195,13 @@ tfp use prod # writes tmp/active (affects all shells without
|
|
|
192
195
|
|
|
193
196
|
### Global flags
|
|
194
197
|
|
|
195
|
-
- `--verbose` - echo the terraform argv to stderr before
|
|
196
|
-
- `--dry-run` - print the argv and
|
|
198
|
+
- `--verbose` - echo the terraform argv to stderr before running it.
|
|
199
|
+
- `--dry-run` - print the argv and run nothing.
|
|
197
200
|
- `-s/--slot <name>` - operate against a specific slot for one invocation.
|
|
198
201
|
|
|
202
|
+
`--verbose` and `--dry-run` are accepted anywhere before a `--`; `-s` goes
|
|
203
|
+
before the subcommand.
|
|
204
|
+
|
|
199
205
|
```sh
|
|
200
206
|
tfp --dry-run plan -t module.foo
|
|
201
207
|
tfp -s prod --verbose apply
|
|
@@ -243,7 +249,7 @@ stale lock on the tfstate. Subsequent runs fail with "state locked".
|
|
|
243
249
|
```sh
|
|
244
250
|
tfp self lock status # lease + lock metadata (exits 2 if locked)
|
|
245
251
|
tfp self lock break # break the lock (prompts for confirmation; -y to skip)
|
|
246
|
-
tfp force-unlock <LOCK_ID>
|
|
252
|
+
tfp tf force-unlock <LOCK_ID> # backend-agnostic, via `tfp tf`
|
|
247
253
|
```
|
|
248
254
|
|
|
249
255
|
`tfp self lock` auto-detects the backend from the active slot's saved state:
|
|
@@ -290,24 +296,27 @@ banner's `project`, `state_key`, `backend_config`, and `env`. `tfp apply`
|
|
|
290
296
|
refuses to run if any of those drift between plan and apply. Pass
|
|
291
297
|
`--force` to override.
|
|
292
298
|
|
|
293
|
-
###
|
|
299
|
+
### Any other Terraform command: `tfp tf`
|
|
294
300
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
slot
|
|
301
|
+
`tfp tf ...` runs any Terraform command verbatim in the active slot, prefixed
|
|
302
|
+
with `-chdir=<source_root>` and the env from the slot's saved state. With no
|
|
303
|
+
active slot it runs Terraform as is:
|
|
298
304
|
|
|
299
305
|
```sh
|
|
300
|
-
tfp validate
|
|
301
|
-
tfp workspace list
|
|
302
|
-
tfp providers schema -json
|
|
303
|
-
tfp version
|
|
306
|
+
tfp tf validate # terraform -chdir=... validate
|
|
307
|
+
tfp tf workspace list # per-slot workspace state via TF_DATA_DIR
|
|
308
|
+
tfp tf providers schema -json
|
|
309
|
+
tfp tf version # works without an active slot
|
|
304
310
|
```
|
|
305
311
|
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
Only the subcommands listed in this README are wrapped; every other
|
|
313
|
+
Terraform command goes through `tfp tf`.
|
|
314
|
+
|
|
315
|
+
Wrapped subcommands accept Terraform's own flags anywhere after the
|
|
316
|
+
subcommand, appended to the underlying invocation; `--` works too:
|
|
308
317
|
|
|
309
318
|
```sh
|
|
310
|
-
tfp plan -t module.foo
|
|
319
|
+
tfp plan -t module.foo -detailed-exitcode -compact-warnings
|
|
311
320
|
tfp apply -- -parallelism=20
|
|
312
321
|
```
|
|
313
322
|
|
|
@@ -326,52 +335,48 @@ tfp self banner check <tfvars> # validate a banner; print resolved slot + f
|
|
|
326
335
|
tfp self snapshot create # `terraform state pull` to <tmp_dir>/snapshots/<slot>/<ts>-manual.tfstate
|
|
327
336
|
tfp self snapshot list # list snapshots for the active slot, newest first
|
|
328
337
|
tfp self snapshot restore [<name>] # `terraform state push -force` the named snapshot (default: newest)
|
|
329
|
-
tfp self trace <subcommand> # print the argv tfp would build;
|
|
338
|
+
tfp self trace <subcommand> # print the argv tfp would build; runs nothing
|
|
330
339
|
tfp self lock status # remote-state lock state (azurerm or s3+dynamodb)
|
|
331
340
|
tfp self lock break # polite-by-default release; --blunt skips terraform
|
|
332
341
|
tfp self providers lock # cross-platform `terraform providers lock`
|
|
333
|
-
tfp force-unlock <LOCK_ID>
|
|
342
|
+
tfp tf force-unlock <LOCK_ID> # backend-agnostic, via `tfp tf`
|
|
334
343
|
```
|
|
335
344
|
|
|
336
|
-
## Migrating from a pre-slot install
|
|
337
|
-
|
|
338
|
-
The first time you run any `tfp` command after upgrading, tf-project detects
|
|
339
|
-
the legacy `tmp/my_terraform_state.json` and promotes it into the new layout
|
|
340
|
-
under `tmp/slots/<slot>/`, sets `tmp/active`, and leaves a one-line
|
|
341
|
-
`tmp/MIGRATED-<UTC-timestamp>.txt` breadcrumb. The first command afterwards
|
|
342
|
-
will repopulate the slot's `.terraform/` from the plugin cache.
|
|
343
|
-
|
|
344
|
-
If the legacy state references a tfvars that has since moved or been deleted,
|
|
345
|
-
migration logs a warning, deletes the legacy file, and asks you to run
|
|
346
|
-
`tfp use <slot>` to start fresh.
|
|
347
|
-
|
|
348
345
|
## Development
|
|
349
346
|
|
|
347
|
+
The program lives in `rust/`. You need the toolchain pinned in
|
|
348
|
+
`rust/rust-toolchain.toml` (rustup installs it on first use) plus
|
|
349
|
+
`cargo-nextest`, `cargo-llvm-cov` and `cargo-deny`.
|
|
350
|
+
|
|
350
351
|
```sh
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
pdm run pytest -m integration # smoke tests (need `terraform` on PATH)
|
|
352
|
+
bin/rust/check.sh # fmt, clippy, docs, licences, tests, 100% coverage
|
|
353
|
+
bin/rust/check.sh --fix # format and apply clippy's fixes first
|
|
354
|
+
bin/run.sh status # run tfp from the source tree
|
|
355
|
+
pip install . # build and install the wheel locally (maturin)
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
+
Tests use fake `terraform` / `az` / `aws` scripts, so they run on macOS and
|
|
359
|
+
Linux without any of those installed. Run them with nextest (as check.sh
|
|
360
|
+
does): each test gets its own process.
|
|
361
|
+
|
|
358
362
|
## Release
|
|
359
363
|
|
|
360
364
|
Releases are **tag-driven**. The wheel's version comes from the git tag,
|
|
361
|
-
not a code edit
|
|
362
|
-
|
|
363
|
-
bump.
|
|
365
|
+
not a code edit: `rust/Cargo.toml` says `0.0.0`, and the release workflow
|
|
366
|
+
writes the tag into it (`bin/rust/set-version.sh`) before building.
|
|
364
367
|
|
|
365
368
|
1. Move the `## [Unreleased]` block in `CHANGELOG.md` under a new
|
|
366
369
|
`## [X.Y.Z] - YYYY-MM-DD` heading. Commit to `main`.
|
|
367
370
|
2. Tag the commit: `git tag vX.Y.Z && git push origin vX.Y.Z`.
|
|
368
371
|
3. The **Release** workflow fires on the tag push:
|
|
369
372
|
- Re-runs CI against the tagged commit.
|
|
370
|
-
- Builds
|
|
371
|
-
|
|
372
|
-
-
|
|
373
|
+
- Builds a wheel per platform (Linux x86_64 + arm64, macOS arm64,
|
|
374
|
+
Windows x86_64) and the sdist, with the version set from the tag.
|
|
375
|
+
- Signs everything with [Sigstore][sigstore] (keyless, transparency-logged).
|
|
376
|
+
- Publishes to PyPI via OIDC trusted publishing.
|
|
373
377
|
- Creates a GitHub Release with the extracted changelog section and the
|
|
374
|
-
signed artifacts
|
|
378
|
+
signed artifacts attached: the wheels and sdist, plus each platform's
|
|
379
|
+
programs as a standalone `.tar.gz` / `.zip` (`bin/rust/archive.py`).
|
|
375
380
|
|
|
376
381
|
Tags carrying `rc` / `a` / `b` / `dev` suffixes (e.g. `v1.0.0rc1`) are
|
|
377
382
|
auto-marked as pre-releases on GitHub.
|
|
@@ -381,3 +386,4 @@ PyPI trusted-publishing is a one-time setup on
|
|
|
381
386
|
`release` GitHub Environment.
|
|
382
387
|
|
|
383
388
|
[sigstore]: https://www.sigstore.dev/
|
|
389
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# tf-project
|
|
2
2
|
|
|
3
3
|
[](https://pypi.org/project/tf-project/)
|
|
4
|
-
[](https://pypi.org/project/tf-project/)
|
|
5
4
|
[](https://github.com/release-art/tf-project/blob/main/LICENSE)
|
|
6
5
|
|
|
7
6
|
A thin, opinionated **Terraform / OpenTofu** wrapper for multi-environment
|
|
@@ -21,9 +20,9 @@ time you switch, this tool replaces that ritual with `tfp use dev`.
|
|
|
21
20
|
swapping between them is instant when both are warm.
|
|
22
21
|
- **Shared provider cache** via `TF_PLUGIN_CACHE_DIR`. Providers download
|
|
23
22
|
once and link into every slot's `.terraform/providers/`.
|
|
24
|
-
- **Versioned,
|
|
23
|
+
- **Versioned, strictly validated state files.** Every persisted JSON carries
|
|
25
24
|
`schema_version`; unknown fields fail loudly (except in user-authored
|
|
26
|
-
banners, where they are tolerated and
|
|
25
|
+
banners, where they are tolerated and reported by `tfp self banner check`).
|
|
27
26
|
- Pluggable tfvars preprocessing - defaults to [1Password's `op inject`][op]
|
|
28
27
|
so you can keep `op://...` references in tfvars committed to git.
|
|
29
28
|
|
|
@@ -32,10 +31,19 @@ time you switch, this tool replaces that ritual with `tfp use dev`.
|
|
|
32
31
|
## Install
|
|
33
32
|
|
|
34
33
|
```sh
|
|
35
|
-
pip install tf-project
|
|
34
|
+
pip install tf-project # or: uv tool install tf-project / pipx install tf-project
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
The CLI is exposed as both `tf-project` and the shorter alias `tfp`.
|
|
37
|
+
The CLI is exposed as both `tf-project` and the shorter alias `tfp`. It is a
|
|
38
|
+
single native program; the PyPI wheels (Linux x86_64 / arm64, macOS arm64,
|
|
39
|
+
Windows x86_64) contain nothing else.
|
|
40
|
+
|
|
41
|
+
To install without Python, download
|
|
42
|
+
`tf-project-<version>-<target>.tar.gz` (`.zip` for Windows) from a
|
|
43
|
+
[GitHub Release][releases] and put `tfp` / `tf-project` on your `PATH`. Every
|
|
44
|
+
release file is signed with [Sigstore][sigstore].
|
|
45
|
+
|
|
46
|
+
[releases]: https://github.com/release-art/tf-project/releases
|
|
39
47
|
|
|
40
48
|
## Configure
|
|
41
49
|
|
|
@@ -57,7 +65,8 @@ tfvars_dir = "tfvars" # scanned for slots; used by `tfp fmt`
|
|
|
57
65
|
tmp_dir = "tmp" # slot dirs + plugin cache land here
|
|
58
66
|
state_key_prefix = "terraform/azure/" # remote backend key prefix
|
|
59
67
|
|
|
60
|
-
# Optional. Defaults to `
|
|
68
|
+
# Optional. Defaults to `terraform` as found on PATH. A bare name (`tofu`) is
|
|
69
|
+
# looked up on PATH when run; a path is taken relative to the project root.
|
|
61
70
|
# terraform_binary = "bin/terraform-1.7.5"
|
|
62
71
|
|
|
63
72
|
# Optional. Defaults to `<tmp_dir>/plugin-cache`. Set to "" to disable.
|
|
@@ -104,14 +113,14 @@ Banner fields:
|
|
|
104
113
|
| `env` | JSON object of `string → string` env vars passed to terraform when running against this slot. |
|
|
105
114
|
| `backend_config` | JSON object of extra `-backend-config k=v` pairs. Wins over the config-level `[tf_project.backend_config]` table. |
|
|
106
115
|
|
|
107
|
-
Unknown banner fields are tolerated (forward-compatible across tfp versions)
|
|
108
|
-
|
|
116
|
+
Unknown banner fields are tolerated (forward-compatible across tfp versions);
|
|
117
|
+
`tfp self banner check` names them, so a typo doesn't disappear silently.
|
|
109
118
|
|
|
110
119
|
## Usage
|
|
111
120
|
|
|
112
121
|
```sh
|
|
113
122
|
tfp use dev # switch to slot "dev" (no init if already warm)
|
|
114
|
-
tfp use tfvars/prod.tfvars #
|
|
123
|
+
tfp use tfvars/prod.tfvars # a tfvars path works too
|
|
115
124
|
tfp init # re-bind the active slot's backend from its banner
|
|
116
125
|
# (run after editing a banner's state_key/backend_config)
|
|
117
126
|
tfp ls # list slots; active marked with `*`
|
|
@@ -135,7 +144,7 @@ tfp state replace-provider hashicorp/aws registry.acme.local/aws
|
|
|
135
144
|
tfp state identities # 1.10+
|
|
136
145
|
tfp import aws_s3_bucket.foo my-bucket
|
|
137
146
|
# forwards the decrypted tfvars + saved env
|
|
138
|
-
tfp status #
|
|
147
|
+
tfp status # summary of the active slot
|
|
139
148
|
tfp last # last terraform invocation for the active slot
|
|
140
149
|
```
|
|
141
150
|
|
|
@@ -157,10 +166,13 @@ tfp use prod # writes tmp/active (affects all shells without
|
|
|
157
166
|
|
|
158
167
|
### Global flags
|
|
159
168
|
|
|
160
|
-
- `--verbose` - echo the terraform argv to stderr before
|
|
161
|
-
- `--dry-run` - print the argv and
|
|
169
|
+
- `--verbose` - echo the terraform argv to stderr before running it.
|
|
170
|
+
- `--dry-run` - print the argv and run nothing.
|
|
162
171
|
- `-s/--slot <name>` - operate against a specific slot for one invocation.
|
|
163
172
|
|
|
173
|
+
`--verbose` and `--dry-run` are accepted anywhere before a `--`; `-s` goes
|
|
174
|
+
before the subcommand.
|
|
175
|
+
|
|
164
176
|
```sh
|
|
165
177
|
tfp --dry-run plan -t module.foo
|
|
166
178
|
tfp -s prod --verbose apply
|
|
@@ -208,7 +220,7 @@ stale lock on the tfstate. Subsequent runs fail with "state locked".
|
|
|
208
220
|
```sh
|
|
209
221
|
tfp self lock status # lease + lock metadata (exits 2 if locked)
|
|
210
222
|
tfp self lock break # break the lock (prompts for confirmation; -y to skip)
|
|
211
|
-
tfp force-unlock <LOCK_ID>
|
|
223
|
+
tfp tf force-unlock <LOCK_ID> # backend-agnostic, via `tfp tf`
|
|
212
224
|
```
|
|
213
225
|
|
|
214
226
|
`tfp self lock` auto-detects the backend from the active slot's saved state:
|
|
@@ -255,24 +267,27 @@ banner's `project`, `state_key`, `backend_config`, and `env`. `tfp apply`
|
|
|
255
267
|
refuses to run if any of those drift between plan and apply. Pass
|
|
256
268
|
`--force` to override.
|
|
257
269
|
|
|
258
|
-
###
|
|
270
|
+
### Any other Terraform command: `tfp tf`
|
|
259
271
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
slot
|
|
272
|
+
`tfp tf ...` runs any Terraform command verbatim in the active slot, prefixed
|
|
273
|
+
with `-chdir=<source_root>` and the env from the slot's saved state. With no
|
|
274
|
+
active slot it runs Terraform as is:
|
|
263
275
|
|
|
264
276
|
```sh
|
|
265
|
-
tfp validate
|
|
266
|
-
tfp workspace list
|
|
267
|
-
tfp providers schema -json
|
|
268
|
-
tfp version
|
|
277
|
+
tfp tf validate # terraform -chdir=... validate
|
|
278
|
+
tfp tf workspace list # per-slot workspace state via TF_DATA_DIR
|
|
279
|
+
tfp tf providers schema -json
|
|
280
|
+
tfp tf version # works without an active slot
|
|
269
281
|
```
|
|
270
282
|
|
|
271
|
-
|
|
272
|
-
|
|
283
|
+
Only the subcommands listed in this README are wrapped; every other
|
|
284
|
+
Terraform command goes through `tfp tf`.
|
|
285
|
+
|
|
286
|
+
Wrapped subcommands accept Terraform's own flags anywhere after the
|
|
287
|
+
subcommand, appended to the underlying invocation; `--` works too:
|
|
273
288
|
|
|
274
289
|
```sh
|
|
275
|
-
tfp plan -t module.foo
|
|
290
|
+
tfp plan -t module.foo -detailed-exitcode -compact-warnings
|
|
276
291
|
tfp apply -- -parallelism=20
|
|
277
292
|
```
|
|
278
293
|
|
|
@@ -291,52 +306,48 @@ tfp self banner check <tfvars> # validate a banner; print resolved slot + f
|
|
|
291
306
|
tfp self snapshot create # `terraform state pull` to <tmp_dir>/snapshots/<slot>/<ts>-manual.tfstate
|
|
292
307
|
tfp self snapshot list # list snapshots for the active slot, newest first
|
|
293
308
|
tfp self snapshot restore [<name>] # `terraform state push -force` the named snapshot (default: newest)
|
|
294
|
-
tfp self trace <subcommand> # print the argv tfp would build;
|
|
309
|
+
tfp self trace <subcommand> # print the argv tfp would build; runs nothing
|
|
295
310
|
tfp self lock status # remote-state lock state (azurerm or s3+dynamodb)
|
|
296
311
|
tfp self lock break # polite-by-default release; --blunt skips terraform
|
|
297
312
|
tfp self providers lock # cross-platform `terraform providers lock`
|
|
298
|
-
tfp force-unlock <LOCK_ID>
|
|
313
|
+
tfp tf force-unlock <LOCK_ID> # backend-agnostic, via `tfp tf`
|
|
299
314
|
```
|
|
300
315
|
|
|
301
|
-
## Migrating from a pre-slot install
|
|
302
|
-
|
|
303
|
-
The first time you run any `tfp` command after upgrading, tf-project detects
|
|
304
|
-
the legacy `tmp/my_terraform_state.json` and promotes it into the new layout
|
|
305
|
-
under `tmp/slots/<slot>/`, sets `tmp/active`, and leaves a one-line
|
|
306
|
-
`tmp/MIGRATED-<UTC-timestamp>.txt` breadcrumb. The first command afterwards
|
|
307
|
-
will repopulate the slot's `.terraform/` from the plugin cache.
|
|
308
|
-
|
|
309
|
-
If the legacy state references a tfvars that has since moved or been deleted,
|
|
310
|
-
migration logs a warning, deletes the legacy file, and asks you to run
|
|
311
|
-
`tfp use <slot>` to start fresh.
|
|
312
|
-
|
|
313
316
|
## Development
|
|
314
317
|
|
|
318
|
+
The program lives in `rust/`. You need the toolchain pinned in
|
|
319
|
+
`rust/rust-toolchain.toml` (rustup installs it on first use) plus
|
|
320
|
+
`cargo-nextest`, `cargo-llvm-cov` and `cargo-deny`.
|
|
321
|
+
|
|
315
322
|
```sh
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
pdm run pytest -m integration # smoke tests (need `terraform` on PATH)
|
|
323
|
+
bin/rust/check.sh # fmt, clippy, docs, licences, tests, 100% coverage
|
|
324
|
+
bin/rust/check.sh --fix # format and apply clippy's fixes first
|
|
325
|
+
bin/run.sh status # run tfp from the source tree
|
|
326
|
+
pip install . # build and install the wheel locally (maturin)
|
|
321
327
|
```
|
|
322
328
|
|
|
329
|
+
Tests use fake `terraform` / `az` / `aws` scripts, so they run on macOS and
|
|
330
|
+
Linux without any of those installed. Run them with nextest (as check.sh
|
|
331
|
+
does): each test gets its own process.
|
|
332
|
+
|
|
323
333
|
## Release
|
|
324
334
|
|
|
325
335
|
Releases are **tag-driven**. The wheel's version comes from the git tag,
|
|
326
|
-
not a code edit
|
|
327
|
-
|
|
328
|
-
bump.
|
|
336
|
+
not a code edit: `rust/Cargo.toml` says `0.0.0`, and the release workflow
|
|
337
|
+
writes the tag into it (`bin/rust/set-version.sh`) before building.
|
|
329
338
|
|
|
330
339
|
1. Move the `## [Unreleased]` block in `CHANGELOG.md` under a new
|
|
331
340
|
`## [X.Y.Z] - YYYY-MM-DD` heading. Commit to `main`.
|
|
332
341
|
2. Tag the commit: `git tag vX.Y.Z && git push origin vX.Y.Z`.
|
|
333
342
|
3. The **Release** workflow fires on the tag push:
|
|
334
343
|
- Re-runs CI against the tagged commit.
|
|
335
|
-
- Builds
|
|
336
|
-
|
|
337
|
-
-
|
|
344
|
+
- Builds a wheel per platform (Linux x86_64 + arm64, macOS arm64,
|
|
345
|
+
Windows x86_64) and the sdist, with the version set from the tag.
|
|
346
|
+
- Signs everything with [Sigstore][sigstore] (keyless, transparency-logged).
|
|
347
|
+
- Publishes to PyPI via OIDC trusted publishing.
|
|
338
348
|
- Creates a GitHub Release with the extracted changelog section and the
|
|
339
|
-
signed artifacts
|
|
349
|
+
signed artifacts attached: the wheels and sdist, plus each platform's
|
|
350
|
+
programs as a standalone `.tar.gz` / `.zip` (`bin/rust/archive.py`).
|
|
340
351
|
|
|
341
352
|
Tags carrying `rc` / `a` / `b` / `dev` suffixes (e.g. `v1.0.0rc1`) are
|
|
342
353
|
auto-marked as pre-releases on GitHub.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
# PEP 621 project metadata
|
|
3
|
+
# See https://www.python.org/dev/peps/pep-0621/
|
|
4
|
+
name = "tf-project"
|
|
5
|
+
description = "Terraform / OpenTofu wrapper with named per-tfvars slots, cached `.terraform/`, 1Password secret injection, and apply-safety guards."
|
|
6
|
+
keywords = [
|
|
7
|
+
"terraform",
|
|
8
|
+
"opentofu",
|
|
9
|
+
"tofu",
|
|
10
|
+
"infrastructure-as-code",
|
|
11
|
+
"iac",
|
|
12
|
+
"devops",
|
|
13
|
+
"cli",
|
|
14
|
+
"wrapper",
|
|
15
|
+
"tfvars",
|
|
16
|
+
"multi-environment",
|
|
17
|
+
"workspaces",
|
|
18
|
+
"1password",
|
|
19
|
+
"op-cli",
|
|
20
|
+
"secrets",
|
|
21
|
+
"azurerm",
|
|
22
|
+
"s3-backend",
|
|
23
|
+
"terraform-state",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
authors = [
|
|
27
|
+
{name = "Ilja Orlovs", email = "ilja@release.art"},
|
|
28
|
+
]
|
|
29
|
+
maintainers = [
|
|
30
|
+
{name = "Ilja Orlovs", email = "ilja@release.art"},
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
dynamic = ["version"]
|
|
34
|
+
|
|
35
|
+
license = "MIT"
|
|
36
|
+
|
|
37
|
+
readme = "README.md"
|
|
38
|
+
|
|
39
|
+
classifiers = [
|
|
40
|
+
"Development Status :: 4 - Beta",
|
|
41
|
+
"Environment :: Console",
|
|
42
|
+
"Intended Audience :: Developers",
|
|
43
|
+
"Intended Audience :: System Administrators",
|
|
44
|
+
"Operating System :: MacOS",
|
|
45
|
+
"Operating System :: Microsoft :: Windows",
|
|
46
|
+
"Operating System :: POSIX :: Linux",
|
|
47
|
+
"Programming Language :: Rust",
|
|
48
|
+
"Topic :: Software Development :: Build Tools",
|
|
49
|
+
"Topic :: System :: Installation/Setup",
|
|
50
|
+
"Topic :: System :: Systems Administration",
|
|
51
|
+
"Topic :: Utilities",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[project.urls]
|
|
55
|
+
Homepage = "https://github.com/release-art/tf-project"
|
|
56
|
+
Repository = "https://github.com/release-art/tf-project"
|
|
57
|
+
Documentation = "https://github.com/release-art/tf-project#readme"
|
|
58
|
+
Changelog = "https://github.com/release-art/tf-project/blob/main/CHANGELOG.md"
|
|
59
|
+
Issues = "https://github.com/release-art/tf-project/issues"
|
|
60
|
+
Releases = "https://github.com/release-art/tf-project/releases"
|
|
61
|
+
|
|
62
|
+
[build-system]
|
|
63
|
+
requires = ["maturin>=1.9.4,<2"]
|
|
64
|
+
build-backend = "maturin"
|
|
65
|
+
|
|
66
|
+
# The wheel holds the two programs `tf-project` and `tfp`, built from rust/ (no Python inside). Its version is
|
|
67
|
+
# rust/Cargo.toml's: 0.0.0 in the tree, set from the release tag (v1.2.3) by bin/rust/set-version.sh.
|
|
68
|
+
[tool.maturin]
|
|
69
|
+
manifest-path = "rust/Cargo.toml"
|
|
70
|
+
bindings = "bin"
|