hashicorp / terraform-provider-vault

Terraform Vault provider
https://www.terraform.io/docs/providers/vault/
Mozilla Public License 2.0
451 stars 535 forks source link

Ensure all mount errors are covered #2289

Closed benashz closed 1 week ago

benashz commented 1 week ago

While working on VSO, we discovered an issue where a read on non-existent mount resulted in an error that prevented the provider from completing successfully.

This PR reworks the error handling for both auth and secret engines.

Additional fixes:

See sample error below for https://github.com/hashicorp/vault-secrets-operator/blob/8ee1ba05f08ea1c74a3cdcc76653908a8ae7f46f/demo/infra/app/auth.tf#L5 :

╷
│ Error: error reading from Vault: Error making API request.
│
│ URL: GET http://127.0.0.1:8200/v1/sys/mounts/auth/demo-auth-mount
│ Code: 400. Errors:
│
│ * No secret engine mount at auth/demo-auth-mount/
│
│   with vault_auth_backend.default,
│   on auth.tf line 5, in resource "vault_auth_backend" "default":
│    5: resource "vault_auth_backend" "default" {
│

The issue seems to also lead to the https://github.com/hashicorp/vault-secrets-operator/actions/runs/9810145898/job/27089804738#step:3:6485