Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Resource "vault_generic_endpoint" - Code: 405. Error: "unsupported operation" #2092

Open
ivankatliarchuk opened this issue Nov 18, 2023 · 5 comments
Labels

Comments

@ivankatliarchuk
Copy link

ivankatliarchuk commented Nov 18, 2023

Terraform Core Version

1.5.5

Terraform Vault Provider Version

3.23.0

Vault Server Version

1.15.1

Affected Resource(s)

  • vault_generic_endpoint

Expected Behavior

The resource will get deleted from state file

Actual Behavior

 Error: error deleting "transit-example/config/keys" from Vault: "Error making API request.\n\nURL: DELETE https://vault.tools-sandbox.xxxxxxxx.com/v1/transit-example/config/keys\nCode: 405. Errors:\n\n* 1 error occurred:\n\t* unsupported operation\n\n"

Why using vault_generic_endpoint for disalbe_upsert . #2091

Relevant Error/Panic Output Snippet

Plan


Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # vault_generic_endpoint.disable_upsert["transit"] will be destroyed
  # (because vault_generic_endpoint.disable_upsert is not in configuration)
  - resource "vault_generic_endpoint" "disable_upsert" {
      - data_json            = (sensitive value) -> null
      - disable_delete       = false -> null
      - disable_read         = false -> null
      - id                   = "transit-example/config/keys" -> null
      - ignore_absent_fields = false -> null
      - path                 = "transit-example/config/keys" -> null
      - write_data           = {} -> null
      - write_data_json      = jsonencode({})
    }

Plan: 0 to add, 0 to change, 1 to destroy.

On apply

vault_generic_endpoint.disable_upsert["transit"]: Destroying... [id=transit/config/keys]
╷
│ Error: error deleting "transit/config/keys" from Vault: "Error making API request.\n\nURL: DELETE https://vault.tools-sandbox.xxxxxxxxxx.com/v1/transit/config/keys\nCode: 405. Errors:\n\n* 1 error occurred:\n\t* unsupported operation\n\n"
│
│
╵
ERRO[0010] terraform invocation failed


### Terraform Configuration Files

```hcl
resource "vault_mount" "this" {
  path                      = "transit-example"
  type                      = "transit"
}

resource "vault_generic_endpoint" "this" {
  path      = "transit-example/config/keys"
  data_json = <<EOT
{
  "disable_upsert": false
}
EOT

  depends_on = [vault_mount.this]
}

Steps to Reproduce

Minimal reproduction snippet

Note: default value is false, so in reality nothing is change
step 1. plan and apply
step 2. comment out resource vault_generic_endpoint
step 3. plan and apply
result: error

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@trodemaster
Copy link

trodemaster commented Nov 24, 2023

Looks like I may be hitting this as well. Using the example code https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/generic_endpoint#example-usage "u1_entity" I'm also getting the Code 405 error.

I noticed that the error shows URL: GET https://vault.local:8200/v1/identity/lookup/entity however when I successfully run this command via CLI it's uses PUT via vault write command instead.

I suspect that this resource is not sending the correct command and ignoring the configuration of disable_read

terraform v1.6.4
vault provider v3.23.0

Update: I revisited this config with fresh eyes. it appears that because I used vault_generic_endpoint without disable_read = true once it was preventing any further plan from succeeding. Once I did a terraform state rm to that resource and applied again with disable_read = true it worked as expected. So watch out for that trap with vault_generic_endpoint.

@ivankatliarchuk
Copy link
Author

I'll re-test. I think I did cover this case too and the behavior was the same.

@dnlopes
Copy link

dnlopes commented Jan 25, 2024

Happening to me as well. Hit this issue after being redirect from #1715.

@javierguzman
Copy link

Hit this as well, does anyone have a workaround? Thanks in advance

@AleksanderDushku
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants