Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Apply fails with Error: 422 Unprocessable Entity #25

Open
mminichino opened this issue Aug 26, 2022 · 4 comments
Open

Apply fails with Error: 422 Unprocessable Entity #25

mminichino opened this issue Aug 26, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@mminichino
Copy link

All attempts to use the provider fail with Error: 422 Unprocessable Entity. I have tried several config combinations. I have tried with an existing project, and with a new project resource. The provider was working yesterday. I don't know what changed. I literally tried the same main.tf that worked yesterday, and now it fails with this error.

main.tf:

terraform {
  required_providers {
    couchbasecapella = {
      source = "couchbasecloud/couchbasecapella"
      version = "0.1.1"
    }
  }
}

provider "couchbasecapella" {}

resource "couchbasecapella_hosted_cluster" "capella_cluster" {
  name        = "dev-01"
  project_id  = "<redacted>"
  place {
    single_az = false
    hosted {
      provider = "aws"
      region   = "us-east-1"
      cidr     = "10.1.2.0/23"
    }
  }
  support_package {
    timezone = "GMT"
    support_package_type     = "DeveloperPro"
  }
  servers {
    size     = "3"
    compute  = "m5.xlarge"
    services = ["data","index","query"]
    storage {
      storage_type = "GP3"
      iops = "3000"
      storage_size = "100"
    }
  }
}

This is the one that worked yesterday, and it now fails with the same error:

terraform {
  required_providers {
    couchbasecapella = {
      source = "couchbasecloud/couchbasecapella"
      version = "0.1.1"
    }
  }
}

provider "couchbasecapella" {}

resource "couchbasecapella_project" "project" {
  name = "dev-01"
}

resource "couchbasecapella_hosted_cluster" "capella_cluster" {
  name        = "dev-01"
  project_id  = couchbasecapella_project.project.id
  place {
    single_az = false
    hosted {
      provider = "aws"
      region   = "us-east-1"
      cidr     = "10.1.2.0/23"
    }
  }
  support_package {
    timezone = "GMT"
    support_package_type     = "DeveloperPro"
  }
  servers {
    size     = "3"
    compute  = "m5.xlarge"
    services = ["data","index","query"]
    storage {
      storage_type = "GP3"
      iops = "3000"
      storage_size = "100"
    }
  }
}

Error:

couchbasecapella_hosted_cluster.capella_cluster: Creating...
2022-08-26T15:03:10.232-0500 [INFO]  Starting apply for couchbasecapella_hosted_cluster.capella_cluster
2022-08-26T15:03:10.232-0500 [DEBUG] couchbasecapella_hosted_cluster.capella_cluster: applying the planned Create change
2022-08-26T15:03:11.099-0500 [ERROR] vertex "couchbasecapella_hosted_cluster.capella_cluster" error: 422 Unprocessable Entity
╷
│ Error: 422 Unprocessable Entity
│
│   with couchbasecapella_hosted_cluster.capella_cluster,
│   on main.tf line 16, in resource "couchbasecapella_hosted_cluster" "capella_cluster":
│   16: resource "couchbasecapella_hosted_cluster" "capella_cluster" {
│
╵
2022-08-26T15:03:11.120-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2022-08-26T15:03:11.123-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/couchbasecloud/couchbasecapella/0.1.1/darwin_amd64/terraform-provider-couchbasecapella_v0.1.1 pid=26961
2022-08-26T15:03:11.123-0500 [DEBUG] provider: plugin exited
@mminichino
Copy link
Author

I don't know what changed, but it is working again.

@jamesrwilkinson
Copy link
Contributor

jamesrwilkinson commented Sep 6, 2022

Hi @mminichino,

This error will likely be due to the cidr field. The 422 error means that the server can understand the request, it is in the correct format but cannot process the instruction. This can happen when the cidr value in the terraform config file is already in use/not available in Capella - a new cluster created on the tenant may use the CIDR block specified in the config file. The deletion of that cluster would result in the availability of that CIDR block again, which would explain why it was working one day and not the next.

I think we can improve the error message in this scenario, where the cidr value is causing the 422 error, to detail that cidr value is in use and suggest using a new value.

@jamesrwilkinson jamesrwilkinson added bug Something isn't working enhancement New feature or request and removed enhancement New feature or request labels Sep 6, 2022
@mike-mini
Copy link

Thanks. I suspected this was the case. A better error message would be great, and also some additional documentation on the registry would be helpful. Outside of examples, there really isn't an explanation of what values are acceptable or not.

@mminichino
Copy link
Author

I'm getting this again and I have tried numerous CIDRs. There really needs to be more verbose details as to what causes this error as it makes it impossible to troubleshoot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants