Prepare for public release #4
+1
-1
@@ -1,4 +1,4 @@
|
||||
/terraform-provider-gpgvaultsecret
|
||||
/terraform-provider-vault-secrets-gpg
|
||||
*.zip
|
||||
*.out
|
||||
*.test
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 IUCLabs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,10 +1,10 @@
|
||||
.PHONY: build install test lint fmt clean tidy package e2e patch minor major check-go
|
||||
.PHONY: build install test lint fmt clean tidy package e2e docs patch minor major check-go
|
||||
|
||||
BINARY := terraform-provider-gpgvaultsecret
|
||||
BINARY := terraform-provider-vault-secrets-gpg
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "0.0.0-dev")
|
||||
OS_ARCH := linux_amd64
|
||||
INSTALL_VERSION := $(shell echo $(VERSION) | sed 's/^v//')
|
||||
INSTALL_DIR := ~/.terraform.d/plugins/git.unkin.net/unkin/gpgvaultsecret/$(INSTALL_VERSION)/$(OS_ARCH)
|
||||
INSTALL_DIR := ~/.terraform.d/plugins/registry.terraform.io/iuclabs/vault-secrets-gpg/$(INSTALL_VERSION)/$(OS_ARCH)
|
||||
ZIP := $(BINARY)_$(INSTALL_VERSION)_$(OS_ARCH).zip
|
||||
|
||||
GO_VERSION_REQUIRED := 1.25
|
||||
@@ -31,12 +31,15 @@ lint: check-go
|
||||
fmt: check-go
|
||||
gofmt -w .
|
||||
|
||||
docs:
|
||||
go generate ./...
|
||||
|
||||
package: build
|
||||
cp $(BINARY) $(BINARY)_v$(INSTALL_VERSION)
|
||||
python3 -c "import zipfile,sys; z=zipfile.ZipFile(sys.argv[1],'w',zipfile.ZIP_DEFLATED); z.write(sys.argv[2]); z.close()" $(ZIP) $(BINARY)_v$(INSTALL_VERSION)
|
||||
rm $(BINARY)_v$(INSTALL_VERSION)
|
||||
|
||||
# End-to-end: boots Vault + LiteLLM + the plugin and applies real terraform.
|
||||
# End-to-end: boots Vault + the gpg plugin and applies real terraform.
|
||||
e2e:
|
||||
./scripts/e2e.sh
|
||||
|
||||
|
||||
@@ -1,96 +1,71 @@
|
||||
# terraform-provider-gpgvaultsecret
|
||||
# Terraform Provider for vault-plugin-secrets-gpg
|
||||
|
||||
A Terraform/OpenTofu provider for the
|
||||
[vault-plugin-secrets-gpg](https://git.unkin.net/unkin/vault-plugin-secrets-gpg)
|
||||
engine. It manages the engine **mount** (and, optionally, plugin catalog
|
||||
registration) and **OpenPGP keys** on HashiCorp Vault or OpenBao.
|
||||
This provider manages the
|
||||
[vault-plugin-secrets-gpg](https://github.com/IUCLabs/vault-plugin-secrets-gpg)
|
||||
secrets engine on HashiCorp Vault or OpenBao, with Terraform or OpenTofu. Use
|
||||
it to mount the engine (and, optionally, register the plugin in the catalog),
|
||||
and to create OpenPGP keys whose private material stays inside Vault.
|
||||
|
||||
The provider's source address is `git.unkin.net/unkin/gpgvaultsecret`; its
|
||||
resources are prefixed `gpg_` (declare it under the local name `gpg`).
|
||||
The registry type is `vault-secrets-gpg`; its resources are prefixed `gpg_`,
|
||||
so declare the provider under the local name `gpg`.
|
||||
|
||||
## Resources & data sources
|
||||
## Quick Start
|
||||
|
||||
| Type | Purpose |
|
||||
|------|---------|
|
||||
| `gpg_secret_backend` (resource) | Mount the gpg engine at a path. When `sha256` is set, register the plugin in the catalog first. |
|
||||
| `gpg_key` (resource) | Create and configure an OpenPGP key (algorithm, identity, exportable, deletion, min decryption version); exposes the armored public key, fingerprint, key id and latest version. |
|
||||
| `gpg_key` (data source) | Read an existing key's metadata + armored public key. |
|
||||
|
||||
## Usage
|
||||
Prebuilt provider archives are on the [releases page](https://github.com/IUCLabs/terraform-provider-vault-secrets-gpg/releases).
|
||||
|
||||
```hcl
|
||||
terraform {
|
||||
required_providers {
|
||||
gpg = {
|
||||
source = "artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/gpgvaultsecret"
|
||||
source = "IUCLabs/vault-secrets-gpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# address and token fall back to VAULT_ADDR and VAULT_TOKEN.
|
||||
provider "gpg" {
|
||||
# address and token fall back to VAULT_ADDR / VAULT_TOKEN
|
||||
address = "https://vault.main.unkin.net"
|
||||
address = "https://vault.example.com:8200"
|
||||
}
|
||||
|
||||
# Mount the engine. Omit sha256 if the plugin is already registered out of band
|
||||
# (e.g. by terraform-vault). Set it to have this resource register the plugin.
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
description = "GPG/OpenPGP secrets engine"
|
||||
# sha256 = "0e92d7408795688badb55789bc1604e8f1dd4d71998656c7f831991fce9a7b20"
|
||||
path = "gpg"
|
||||
}
|
||||
|
||||
resource "gpg_key" "app" {
|
||||
backend = gpg_secret_backend.gpg.path
|
||||
name = "app"
|
||||
algorithm = "rsa-4096" # rsa-2048 | rsa-3072 | rsa-4096 | ed25519
|
||||
identity = "App <app@unkin.net>"
|
||||
algorithm = "rsa-4096"
|
||||
identity = "App <app@example.com>"
|
||||
}
|
||||
|
||||
# Wire the armored public key somewhere (e.g. a pass store, a k8s secret).
|
||||
output "app_public_key" {
|
||||
value = gpg_key.app.public_key
|
||||
}
|
||||
```
|
||||
|
||||
### `gpg_secret_backend`
|
||||
## Requirements
|
||||
|
||||
| Attribute | | Description |
|
||||
|-----------|-----|-------------|
|
||||
| `path` | required, force-new | Mount path (e.g. `gpg`). |
|
||||
| `plugin` | optional, force-new | Registered plugin name/mount type. Default `vault-plugin-secrets-gpg`. |
|
||||
| `description` | optional | Mount description. |
|
||||
| `sha256` | optional | If set, (re)register the plugin in the catalog with this binary hash before mounting. |
|
||||
| `command` | optional | Binary filename in the server `plugin_directory` used for registration. Defaults to `plugin`. |
|
||||
- [Terraform](https://developer.hashicorp.com/terraform/downloads) 1.0+ or [OpenTofu](https://opentofu.org/)
|
||||
- HashiCorp Vault or OpenBao, with the
|
||||
[vault-plugin-secrets-gpg](https://github.com/IUCLabs/vault-plugin-secrets-gpg)
|
||||
binary in the server's `plugin_directory` (see that repo for the server
|
||||
versions it is tested against)
|
||||
- [Go](https://go.dev/doc/install) 1.25+ (only if you build from source)
|
||||
|
||||
Import: `terraform import gpg_secret_backend.gpg gpg`.
|
||||
## Usage
|
||||
|
||||
### `gpg_key`
|
||||
See the [docs](docs/index.md) for the provider, `gpg_secret_backend`,
|
||||
`gpg_key` and the `gpg_key` data source.
|
||||
|
||||
| Attribute | | Description |
|
||||
|-----------|-----|-------------|
|
||||
| `backend` | required, force-new | Mount path of the engine. |
|
||||
| `name` | required, force-new | Key name. |
|
||||
| `algorithm` | optional, force-new | `rsa-2048` / `rsa-3072` (default) / `rsa-4096` / `ed25519`. |
|
||||
| `identity` | optional, force-new | OpenPGP User ID. Defaults to the key name. |
|
||||
| `exportable` | optional | Allow private-key export (enable-only). |
|
||||
| `deletion_allowed` | optional | Whether the key may be deleted. `terraform destroy` enables this automatically. |
|
||||
| `min_decryption_version` | optional | Minimum version usable for decrypt/verify. |
|
||||
| `latest_version`, `fingerprint`, `key_id`, `public_key` | computed | Current key material metadata. |
|
||||
|
||||
Import: `terraform import gpg_key.app gpg/app`.
|
||||
|
||||
## Build
|
||||
## Development
|
||||
|
||||
```sh
|
||||
make build # -> terraform-provider-gpgvaultsecret
|
||||
make install # into ~/.terraform.d/plugins/... for local use
|
||||
make test # go test -race (unit tests; no Vault needed)
|
||||
make e2e # real terraform apply/destroy against a Vault dev server + the gpg plugin
|
||||
make package # zip for the artifactapi terraform registry
|
||||
make build # build the provider binary
|
||||
make test # unit tests
|
||||
make docs # regenerate docs/ from the schema and examples/
|
||||
make e2e # apply real Terraform against a Vault dev server
|
||||
```
|
||||
|
||||
CI (Woodpecker) runs pre-commit/build/lint/test on PRs. On a `v*` tag it builds
|
||||
and PUTs `terraform-provider-gpgvaultsecret_<version>_linux_amd64.zip` to the
|
||||
artifactapi `terraform-unkin` registry (GPG-signed server-side), installable via
|
||||
the bare `source = "artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/gpgvaultsecret"`.
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "gpg_key Data Source - gpg"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Reads an OpenPGP key's metadata and armored public key from a gpg secrets engine mount.
|
||||
---
|
||||
|
||||
# gpg_key (Data Source)
|
||||
|
||||
Reads an OpenPGP key's metadata and armored public key from a gpg secrets engine mount.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
}
|
||||
|
||||
output "app_fingerprint" {
|
||||
value = data.gpg_key.app.fingerprint
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `backend` (String) Mount path of the gpg secrets engine.
|
||||
- `name` (String) Name of the key.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `algorithm` (String) Key algorithm.
|
||||
- `deletion_allowed` (Boolean) Whether the key may be deleted.
|
||||
- `exportable` (Boolean) Whether the private key is exportable.
|
||||
- `fingerprint` (String) OpenPGP fingerprint of the latest version.
|
||||
- `identity` (String) OpenPGP User ID.
|
||||
- `key_id` (String) OpenPGP key ID of the latest version.
|
||||
- `latest_version` (Number) Current (highest) key version.
|
||||
- `min_decryption_version` (Number) Minimum key version usable for decryption.
|
||||
- `public_key` (String) Armored public key of the latest version.
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "gpg Provider"
|
||||
description: |-
|
||||
Manage the vault-plugin-secrets-gpg https://github.com/IUCLabs/vault-plugin-secrets-gpg secrets engine (mounts and OpenPGP keys) on HashiCorp Vault or OpenBao.
|
||||
Resources and data sources use the gpg_ prefix, so declare the provider under the local name gpg in required_providers.
|
||||
---
|
||||
|
||||
# gpg Provider
|
||||
|
||||
Manage the [vault-plugin-secrets-gpg](https://github.com/IUCLabs/vault-plugin-secrets-gpg) secrets engine (mounts and OpenPGP keys) on HashiCorp Vault or OpenBao.
|
||||
|
||||
Resources and data sources use the `gpg_` prefix, so declare the provider under the local name `gpg` in `required_providers`.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
gpg = {
|
||||
source = "IUCLabs/vault-secrets-gpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# address and token fall back to VAULT_ADDR and VAULT_TOKEN.
|
||||
provider "gpg" {
|
||||
address = "https://vault.example.com:8200"
|
||||
}
|
||||
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
}
|
||||
|
||||
resource "gpg_key" "app" {
|
||||
backend = gpg_secret_backend.gpg.path
|
||||
name = "app"
|
||||
identity = "App <app@example.com>"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Optional
|
||||
|
||||
- `address` (String) Address of the Vault/OpenBao server. Falls back to the VAULT_ADDR environment variable.
|
||||
- `token` (String, Sensitive) Token used to authenticate to Vault/OpenBao. Falls back to the VAULT_TOKEN environment variable.
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "gpg_key Resource - gpg"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Manages an OpenPGP key in a gpg secrets engine mount.
|
||||
---
|
||||
|
||||
# gpg_key (Resource)
|
||||
|
||||
Manages an OpenPGP key in a gpg secrets engine mount.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
resource "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
algorithm = "rsa-4096"
|
||||
identity = "App <app@example.com>"
|
||||
}
|
||||
|
||||
output "app_public_key" {
|
||||
value = gpg_key.app.public_key
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `backend` (String) Mount path of the gpg secrets engine (e.g. "gpg"). Changing this forces a new key.
|
||||
- `name` (String) Name of the key. Changing this forces a new key.
|
||||
|
||||
### Optional
|
||||
|
||||
- `algorithm` (String) Key algorithm: rsa-2048, rsa-3072, rsa-4096 or ed25519. Defaults to rsa-3072. Changing this forces a new key.
|
||||
- `deletion_allowed` (Boolean) Whether the key may be deleted. Terraform enables this automatically on destroy. Defaults to false.
|
||||
- `exportable` (Boolean) Allow exporting the private key. Can be enabled later but never disabled. Defaults to false.
|
||||
- `identity` (String) OpenPGP User ID (e.g. "Jane Doe <jane@example.com>"). Defaults to the key name. Changing this forces a new key.
|
||||
- `min_decryption_version` (Number) Minimum key version usable for decryption. Must be between 1 and `latest_version`, otherwise the write fails. Defaults to 1.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `fingerprint` (String) OpenPGP fingerprint of the latest version.
|
||||
- `key_id` (String) OpenPGP key ID of the latest version.
|
||||
- `latest_version` (Number) The current (highest) key version.
|
||||
- `public_key` (String) Armored public key of the latest version (import into gpg/pass to encrypt to this key).
|
||||
|
||||
## Import
|
||||
|
||||
Import is supported using the following syntax:
|
||||
|
||||
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
|
||||
|
||||
```shell
|
||||
# Import by <backend>/<name>.
|
||||
terraform import gpg_key.app gpg/app
|
||||
```
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "gpg_secret_backend Resource - gpg"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Mounts the gpg secrets engine. Optionally registers the plugin in the catalog first when a sha256 is given.
|
||||
---
|
||||
|
||||
# gpg_secret_backend (Resource)
|
||||
|
||||
Mounts the gpg secrets engine. Optionally registers the plugin in the catalog first when a sha256 is given.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
# Mount a plugin that is already registered in the catalog.
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
description = "OpenPGP keys"
|
||||
}
|
||||
|
||||
# Register the binary in the server's plugin_directory, then mount it.
|
||||
variable "plugin_sha256" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "gpg_secret_backend" "registered" {
|
||||
path = "gpg-registered"
|
||||
sha256 = var.plugin_sha256
|
||||
command = "vault-plugin-secrets-gpg"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `path` (String) Mount path for the gpg secrets engine (e.g. "gpg"). Changing this forces a new mount.
|
||||
|
||||
### Optional
|
||||
|
||||
- `command` (String) Plugin binary filename (relative to the server plugin_directory) used when registering. Defaults to the plugin name. Only used when sha256 is set.
|
||||
- `description` (String) Human-readable description of the mount.
|
||||
- `plugin` (String) Registered plugin name (mount type). Defaults to vault-plugin-secrets-gpg. Changing this forces a new mount.
|
||||
- `sha256` (String) SHA-256 of the plugin binary. When set, the plugin is (re)registered in the catalog before mounting; omit if the plugin is already registered out of band.
|
||||
|
||||
## Import
|
||||
|
||||
Import is supported using the following syntax:
|
||||
|
||||
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
|
||||
|
||||
```shell
|
||||
# Import by mount path.
|
||||
terraform import gpg_secret_backend.gpg gpg
|
||||
```
|
||||
@@ -0,0 +1,8 @@
|
||||
data "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
}
|
||||
|
||||
output "app_fingerprint" {
|
||||
value = data.gpg_key.app.fingerprint
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
data "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
}
|
||||
|
||||
# e.g. import into a pass store or hand to another system
|
||||
output "app_public_key" {
|
||||
value = data.gpg_key.app.public_key
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
gpg = {
|
||||
source = "IUCLabs/vault-secrets-gpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# address and token fall back to VAULT_ADDR and VAULT_TOKEN.
|
||||
provider "gpg" {
|
||||
address = "https://vault.example.com:8200"
|
||||
}
|
||||
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
}
|
||||
|
||||
resource "gpg_key" "app" {
|
||||
backend = gpg_secret_backend.gpg.path
|
||||
name = "app"
|
||||
identity = "App <app@example.com>"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# Import by <backend>/<name>.
|
||||
terraform import gpg_key.app gpg/app
|
||||
@@ -1,15 +0,0 @@
|
||||
resource "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
algorithm = "rsa-4096" # rsa-2048 | rsa-3072 | rsa-4096 | ed25519
|
||||
identity = "App <app@unkin.net>"
|
||||
exportable = false
|
||||
}
|
||||
|
||||
output "app_public_key" {
|
||||
value = gpg_key.app.public_key
|
||||
}
|
||||
|
||||
output "app_fingerprint" {
|
||||
value = gpg_key.app.fingerprint
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
resource "gpg_key" "app" {
|
||||
backend = "gpg"
|
||||
name = "app"
|
||||
algorithm = "rsa-4096"
|
||||
identity = "App <app@example.com>"
|
||||
}
|
||||
|
||||
output "app_public_key" {
|
||||
value = gpg_key.app.public_key
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# Import by mount path.
|
||||
terraform import gpg_secret_backend.gpg gpg
|
||||
@@ -1,9 +0,0 @@
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
description = "GPG/OpenPGP secrets engine"
|
||||
|
||||
# Optional: have this resource register the plugin in the catalog. Omit if the
|
||||
# plugin is already registered (e.g. by terraform-vault).
|
||||
# sha256 = "0e92d7408795688badb55789bc1604e8f1dd4d71998656c7f831991fce9a7b20"
|
||||
# command = "vault-plugin-secrets-gpg"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
# Mount a plugin that is already registered in the catalog.
|
||||
resource "gpg_secret_backend" "gpg" {
|
||||
path = "gpg"
|
||||
description = "OpenPGP keys"
|
||||
}
|
||||
|
||||
# Register the binary in the server's plugin_directory, then mount it.
|
||||
variable "plugin_sha256" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "gpg_secret_backend" "registered" {
|
||||
path = "gpg-registered"
|
||||
sha256 = var.plugin_sha256
|
||||
command = "vault-plugin-secrets-gpg"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
module git.unkin.net/unkin/terraform-provider-gpgvaultsecret
|
||||
module github.com/IUCLabs/terraform-provider-vault-secrets-gpg
|
||||
|
||||
go 1.25
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func (d *keyDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, re
|
||||
"identity": schema.StringAttribute{Description: "OpenPGP User ID.", Computed: true},
|
||||
"exportable": schema.BoolAttribute{Description: "Whether the private key is exportable.", Computed: true},
|
||||
"deletion_allowed": schema.BoolAttribute{Description: "Whether the key may be deleted.", Computed: true},
|
||||
"min_decryption_version": schema.Int64Attribute{Description: "Minimum usable version for decryption/verification.", Computed: true},
|
||||
"min_decryption_version": schema.Int64Attribute{Description: "Minimum key version usable for decryption.", Computed: true},
|
||||
"latest_version": schema.Int64Attribute{Description: "Current (highest) key version.", Computed: true},
|
||||
"fingerprint": schema.StringAttribute{Description: "OpenPGP fingerprint of the latest version.", Computed: true},
|
||||
"key_id": schema.StringAttribute{Description: "OpenPGP key ID of the latest version.", Computed: true},
|
||||
|
||||
@@ -29,7 +29,7 @@ func New(version string) func() provider.Provider {
|
||||
}
|
||||
|
||||
func (p *gpgProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
|
||||
// The provider's source address is git.unkin.net/unkin/gpgvaultsecret, but
|
||||
// The provider's source address is IUCLabs/vault-secrets-gpg, but
|
||||
// its resources are prefixed "gpg_" (declare it in required_providers under
|
||||
// the local name "gpg"), mirroring how google-beta ships google_*.
|
||||
resp.TypeName = "gpg"
|
||||
@@ -39,6 +39,9 @@ func (p *gpgProvider) Metadata(_ context.Context, _ provider.MetadataRequest, re
|
||||
func (p *gpgProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
|
||||
resp.Schema = schema.Schema{
|
||||
Description: "Manage the vault-plugin-secrets-gpg engine — mounts and OpenPGP keys — on HashiCorp Vault or OpenBao.",
|
||||
MarkdownDescription: "Manage the [vault-plugin-secrets-gpg](https://github.com/IUCLabs/vault-plugin-secrets-gpg) " +
|
||||
"secrets engine (mounts and OpenPGP keys) on HashiCorp Vault or OpenBao.\n\n" +
|
||||
"Resources and data sources use the `gpg_` prefix, so declare the provider under the local name `gpg` in `required_providers`.",
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"address": schema.StringAttribute{
|
||||
Description: "Address of the Vault/OpenBao server. Falls back to the VAULT_ADDR environment variable.",
|
||||
|
||||
@@ -54,42 +54,42 @@ func (r *keyResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
|
||||
Description: "Manages an OpenPGP key in a gpg secrets engine mount.",
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"backend": schema.StringAttribute{
|
||||
Description: "Mount path of the gpg secrets engine (e.g. \"gpg\").",
|
||||
Description: "Mount path of the gpg secrets engine (e.g. \"gpg\"). Changing this forces a new key.",
|
||||
Required: true,
|
||||
PlanModifiers: requiresReplace,
|
||||
},
|
||||
"name": schema.StringAttribute{
|
||||
Description: "Name of the key.",
|
||||
Description: "Name of the key. Changing this forces a new key.",
|
||||
Required: true,
|
||||
PlanModifiers: requiresReplace,
|
||||
},
|
||||
"algorithm": schema.StringAttribute{
|
||||
Description: "Key algorithm: rsa-2048, rsa-3072, rsa-4096 or ed25519.",
|
||||
Description: "Key algorithm: rsa-2048, rsa-3072, rsa-4096 or ed25519. Defaults to rsa-3072. Changing this forces a new key.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: stringdefault.StaticString("rsa-3072"),
|
||||
PlanModifiers: requiresReplace,
|
||||
},
|
||||
"identity": schema.StringAttribute{
|
||||
Description: "OpenPGP User ID (e.g. \"Me <me@example>\"). Defaults to the key name.",
|
||||
Description: "OpenPGP User ID (e.g. \"Jane Doe <jane@example.com>\"). Defaults to the key name. Changing this forces a new key.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
PlanModifiers: requiresReplace,
|
||||
},
|
||||
"exportable": schema.BoolAttribute{
|
||||
Description: "Allow exporting the private key. Can be enabled later but never disabled.",
|
||||
Description: "Allow exporting the private key. Can be enabled later but never disabled. Defaults to false.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"deletion_allowed": schema.BoolAttribute{
|
||||
Description: "Whether the key may be deleted. Terraform enables this automatically on destroy.",
|
||||
Description: "Whether the key may be deleted. Terraform enables this automatically on destroy. Defaults to false.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"min_decryption_version": schema.Int64Attribute{
|
||||
Description: "Minimum key version usable for decryption and verification.",
|
||||
Description: "Minimum key version usable for decryption. Must be between 1 and `latest_version`, otherwise the write fails. Defaults to 1.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -46,14 +46,14 @@ func (r *secretBackendResource) Schema(_ context.Context, _ resource.SchemaReque
|
||||
Description: "Mounts the gpg secrets engine. Optionally registers the plugin in the catalog first when a sha256 is given.",
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"path": schema.StringAttribute{
|
||||
Description: "Mount path for the gpg secrets engine (e.g. \"gpg\").",
|
||||
Description: "Mount path for the gpg secrets engine (e.g. \"gpg\"). Changing this forces a new mount.",
|
||||
Required: true,
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.RequiresReplace(),
|
||||
},
|
||||
},
|
||||
"plugin": schema.StringAttribute{
|
||||
Description: "Registered plugin name/type to mount.",
|
||||
Description: "Registered plugin name (mount type). Defaults to vault-plugin-secrets-gpg. Changing this forces a new mount.",
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: stringdefault.StaticString(defaultPluginType),
|
||||
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/providerserver"
|
||||
|
||||
"git.unkin.net/unkin/terraform-provider-gpgvaultsecret/internal/provider"
|
||||
"github.com/IUCLabs/terraform-provider-vault-secrets-gpg/internal/provider"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0 generate --provider-name gpg
|
||||
|
||||
var version = "0.0.1"
|
||||
|
||||
func main() {
|
||||
@@ -18,7 +20,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
opts := providerserver.ServeOpts{
|
||||
Address: "git.unkin.net/unkin/gpgvaultsecret",
|
||||
Address: "registry.terraform.io/iuclabs/vault-secrets-gpg",
|
||||
Debug: debug,
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# End-to-end test for terraform-provider-gpgvaultsecret. Boots a Vault dev server
|
||||
# End-to-end test for terraform-provider-vault-secrets-gpg. Boots a Vault dev server
|
||||
# running the vault-plugin-secrets-gpg engine, then applies real terraform that
|
||||
# registers + mounts the backend, creates a key, and reads it via the data
|
||||
# source. Verifies the outputs and that the mounted engine actually works, then
|
||||
@@ -37,7 +37,7 @@ trap cleanup EXIT
|
||||
|
||||
blue "Building provider"
|
||||
make -C "${ROOT_DIR}" build >/dev/null
|
||||
PROVIDER_BIN="${ROOT_DIR}/terraform-provider-gpgvaultsecret"
|
||||
PROVIDER_BIN="${ROOT_DIR}/terraform-provider-vault-secrets-gpg"
|
||||
|
||||
blue "Starting Vault dev server (plugin_directory=${PLUGIN_DIR})"
|
||||
vault server -dev -dev-root-token-id=root -dev-listen-address=127.0.0.1:8282 \
|
||||
@@ -54,7 +54,7 @@ green "vault ready"
|
||||
cat > "${WORK}/dev.tfrc" <<EOF
|
||||
provider_installation {
|
||||
dev_overrides {
|
||||
"git.unkin.net/unkin/gpgvaultsecret" = "$(dirname "${PROVIDER_BIN}")"
|
||||
"registry.terraform.io/iuclabs/vault-secrets-gpg" = "$(dirname "${PROVIDER_BIN}")"
|
||||
}
|
||||
direct {}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
gpg = {
|
||||
source = "git.unkin.net/unkin/gpgvaultsecret"
|
||||
source = "IUCLabs/vault-secrets-gpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ resource "gpg_key" "app" {
|
||||
backend = gpg_secret_backend.gpg.path
|
||||
name = "app"
|
||||
algorithm = "rsa-2048"
|
||||
identity = "App <app@unkin.net>"
|
||||
identity = "App <app@example.com>"
|
||||
exportable = false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user