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

"Error: error deleting organization information" When importing organization #1327

Closed
emoreth opened this issue Jul 18, 2023 · 3 comments
Closed
Assignees
Labels

Comments

@emoreth
Copy link

emoreth commented Jul 18, 2023

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.3.6
on darwin_arm64
+ provider registry.terraform.io/mongodb/mongodbatlas v1.10.1

Terraform Configuration File

terraform {
  required_providers {
    mongodbatlas = {
      source = "mongodb/mongodbatlas"
      version = "1.10.1"
    }
  }
  required_version = "~> 1.3"
}

provider "mongodbatlas" {
  public_key = "[REDACTED]"
  private_key  = "[REDACTED]"
}

resource "mongodbatlas_organization" "example" {
  org_owner_id = "[REDACTED]"
  name = "Example"
  description = "Terraform Prod API KEY"
  role_names = ["ORG_OWNER"]
}

Steps to Reproduce

TF_LOG=debug terraform import mongodbatlas_organization.example 64[REDACTED]21

Expected Behavior

Terraform should have imported the org data.

Actual Behavior

Error: error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource.

Debug Output

2023-07-17T22:58:42.560-0300 [INFO]  Terraform version: 1.3.6
2023-07-17T22:58:42.560-0300 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2023-07-17T22:58:42.560-0300 [DEBUG] using github.com/hashicorp/hcl/v2 v2.15.0
2023-07-17T22:58:42.560-0300 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2023-07-17T22:58:42.560-0300 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2023-07-17T22:58:42.560-0300 [DEBUG] using github.com/zclconf/go-cty v1.12.1
2023-07-17T22:58:42.560-0300 [INFO]  Go runtime version: go1.19.3
2023-07-17T22:58:42.560-0300 [INFO]  CLI args: []string{"terraform", "import", "mongodbatlas_organization.example", "64[REDACTED]21"}
2023-07-17T22:58:42.560-0300 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc
2023-07-17T22:58:42.560-0300 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2023-07-17T22:58:42.560-0300 [INFO]  Loading CLI configuration from /Users/user/.terraform.d/credentials.tfrc.json
2023-07-17T22:58:42.561-0300 [DEBUG] checking for credentials in "/Users/user/.terraform.d/plugins"
2023-07-17T22:58:42.561-0300 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2023-07-17T22:58:42.561-0300 [DEBUG] will search for provider plugins in /Users/user/.terraform.d/plugins
2023-07-17T22:58:42.561-0300 [DEBUG] ignoring non-existing provider search directory /Users/user/Library/Application Support/io.terraform/plugins
2023-07-17T22:58:42.561-0300 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2023-07-17T22:58:42.562-0300 [INFO]  CLI command args: []string{"import", "mongodbatlas_organization.example", "64[REDACTED]21"}
2023-07-17T22:58:42.568-0300 [DEBUG] New state was assigned lineage "e34b7875-b556-78f2-4431-f4e92d4a682a"
2023-07-17T22:58:42.597-0300 [DEBUG] checking for provisioner in "."
2023-07-17T22:58:42.597-0300 [DEBUG] checking for provisioner in "/usr/local/bin"
2023-07-17T22:58:42.597-0300 [DEBUG] checking for provisioner in "/Users/user/.terraform.d/plugins"
2023-07-17T22:58:42.601-0300 [DEBUG] Building and walking import graph
2023-07-17T22:58:42.603-0300 [DEBUG] Not attaching any node states: overall state is nil
2023-07-17T22:58:42.603-0300 [DEBUG] No state, no orphan outputs
2023-07-17T22:58:42.604-0300 [DEBUG] ProviderTransformer: "mongodbatlas_organization.example (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/mongodb/mongodbatlas"]
2023-07-17T22:58:42.604-0300 [DEBUG] ProviderTransformer: "mongodbatlas_project.backend (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/mongodb/mongodbatlas"]
2023-07-17T22:58:42.604-0300 [DEBUG] ProviderTransformer: "mongodbatlas_organization.example (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/mongodb/mongodbatlas"]
2023-07-17T22:58:42.604-0300 [DEBUG] created provider logger: level=debug
2023-07-17T22:58:42.604-0300 [INFO]  provider: configuring client automatic mTLS
2023-07-17T22:58:42.613-0300 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 args=[.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1]
2023-07-17T22:58:42.615-0300 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 pid=20823
2023-07-17T22:58:42.615-0300 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1
2023-07-17T22:58:42.628-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: configuring server automatic mTLS: timestamp=2023-07-17T22:58:42.628-0300
2023-07-17T22:58:42.635-0300 [DEBUG] provider: using plugin: version=5
2023-07-17T22:58:42.635-0300 [DEBUG] provider.terraform-provider-mongodbatlas_v1.10.1: plugin address: address=/var/folders/t6/tm20syfx2_v2dsd6b9lpg6600000gn/T/plugin3526837838 network=unix timestamp=2023-07-17T22:58:42.635-0300
2023-07-17T22:58:42.657-0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-07-17T22:58:42.658-0300 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 pid=20823
2023-07-17T22:58:42.658-0300 [DEBUG] provider: plugin exited
2023-07-17T22:58:42.658-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_organization.example (expand)" references: []
2023-07-17T22:58:42.658-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_project.backend (expand)" references: []
2023-07-17T22:58:42.658-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_organization.example (expand)" references: []
2023-07-17T22:58:42.658-0300 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" references: []
2023-07-17T22:58:42.658-0300 [DEBUG] Starting graph walk: walkImport
2023-07-17T22:58:42.659-0300 [DEBUG] created provider logger: level=debug
2023-07-17T22:58:42.659-0300 [INFO]  provider: configuring client automatic mTLS
2023-07-17T22:58:42.663-0300 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 args=[.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1]
2023-07-17T22:58:42.664-0300 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 pid=20824
2023-07-17T22:58:42.664-0300 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1
2023-07-17T22:58:42.671-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: configuring server automatic mTLS: timestamp=2023-07-17T22:58:42.671-0300
2023-07-17T22:58:42.677-0300 [DEBUG] provider: using plugin: version=5
2023-07-17T22:58:42.677-0300 [DEBUG] provider.terraform-provider-mongodbatlas_v1.10.1: plugin address: address=/var/folders/t6/tm20syfx2_v2dsd6b9lpg6600000gn/T/plugin2323813325 network=unix timestamp=2023-07-17T22:58:42.677-0300
2023-07-17T22:58:42.693-0300 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" changed the config value, but that value is unused
2023-07-17T22:58:42.694-0300 [DEBUG] Resource instance state not found for node "mongodbatlas_project.backend", instance mongodbatlas_project.backend
2023-07-17T22:58:42.694-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_project.backend" references: []
2023-07-17T22:58:42.694-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_organization.example (import id \"64[REDACTED]21\")" references: []
mongodbatlas_organization.example: Importing from ID "64[REDACTED]21"...
2023-07-17T22:58:42.694-0300 [DEBUG] Resource instance state not found for node "mongodbatlas_organization.example", instance mongodbatlas_organization.example
2023-07-17T22:58:42.694-0300 [DEBUG] ReferenceTransformer: "mongodbatlas_organization.example" references: []
2023-07-17T22:58:42.695-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: 2023/07/17 22:58:42 [DEBUG] MongoDB Atlas API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/atlas/v1.0/orgs/64[REDACTED]21 HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.10.1 go-mongodbatlas/0.31.0 (darwin;arm64)
Accept: application/json
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2023-07-17T22:58:42.695-0300
2023-07-17T22:58:43.328-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: 2023/07/17 22:58:43 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Content-Type: application/json
Date: Tue, 18 Jul 2023 01:58:43 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 16
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=8ce6d00c99bcaf9303548c6af2a71f82ed21525f; versionString=v20230712
X-Permitted-Cross-Domain-Policies: none

{
"id": "64[REDACTED]21",
"isDeleted": false,
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21",
"rel": "self"
},
{
"href": "https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21/groups",
"rel": "https://cloud.mongodb.com/groups"
},
{
"href": "https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21/teams",
"rel": "https://cloud.mongodb.com/teams"
},
{
"href": "https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21/users",
"rel": "https://cloud.mongodb.com/users"
}
],
"name": "example"
}
-----------------------------------------------------: timestamp=2023-07-17T22:58:43.328-0300
mongodbatlas_organization.example: Import prepared!
Prepared mongodbatlas_organization for import
mongodbatlas_organization.example: Refreshing state... [id=b3JnX2lk:NjRhOWY5ZGNkZDQwZTY1NTAyMDkyNDIx]
2023-07-17T22:58:43.333-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: 2023/07/17 22:58:43 [DEBUG] MongoDB Atlas API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/atlas/v1.0/orgs/64[REDACTED]21 HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.10.1 go-mongodbatlas/0.31.0 (darwin;arm64)
Accept: application/json
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2023-07-17T22:58:43.333-0300
2023-07-17T22:58:43.637-0300 [INFO]  provider.terraform-provider-mongodbatlas_v1.10.1: 2023/07/17 22:58:43 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 401 Unauthorized
Content-Length: 106
Content-Type: application/json
Date: Tue, 18 Jul 2023 01:58:43 GMT
Server: mdbws
Www-Authenticate: Digest realm="MMS Public API", domain="", nonce="I+xG4xb7bUgq8uMBCuAxZPI+VDDcJ9q1", algorithm=MD5, qop="auth", stale=false
X-Envoy-Upstream-Service-Time: 6

{
"error" : 401,
"reason" : "Unauthorized",
"detail" : "You are not authorized for this resource."
}
-----------------------------------------------------: timestamp=2023-07-17T22:58:43.637-0300
2023-07-17T22:58:43.638-0300 [ERROR] provider.terraform-provider-mongodbatlas_v1.10.1: Response contains error diagnostic: diagnostic_detail= diagnostic_summary="error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource." tf_rpc=ReadResource @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_severity=ERROR tf_proto_version=5.3 tf_provider_addr=provider tf_req_id=7698c4a5-ad6b-a0a3-bc07-acda6793521b tf_resource_type=mongodbatlas_organization timestamp=2023-07-17T22:58:43.638-0300
2023-07-17T22:58:43.639-0300 [ERROR] vertex "import mongodbatlas_organization.example result" error: error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource.
2023-07-17T22:58:43.639-0300 [ERROR] vertex "mongodbatlas_organization.example (import id \"64[REDACTED]21\")" error: error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource.
2023-07-17T22:58:43.639-0300 [ERROR] vertex "mongodbatlas_organization.example (expand)" error: error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource.
╷
│ Error: error deleting organization information: GET https://cloud.mongodb.com/api/atlas/v1.0/orgs/64[REDACTED]21: 401 (request "") You are not authorized for this resource.
│
│
╵

2023-07-17T22:58:43.641-0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-07-17T22:58:43.643-0300 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.10.1/darwin_arm64/terraform-provider-mongodbatlas_v1.10.1 pid=20824
2023-07-17T22:58:43.643-0300 [DEBUG] provider: plugin exited

Crash Output

Additional Context

References

@github-actions
Copy link
Contributor

Thanks for opening this issue. The ticket INTMDB-944 was created for internal tracking.

@andreaangiolillo
Copy link
Collaborator

Hello 👋
Thanks for opening the issue. I am updating the error message shown when the read operation returns an error in #1352.

The reason why the read operation is failing seems related to the permissions associated with the provided API keys. Make sure that the requesting API Key have the Organization Owner role and that the requesting API Key's organization is a paying organization.

Thanks

@andreaangiolillo
Copy link
Collaborator

Hello,
The fix was released in v1.11.0.. Feel free to reopen the issue if you still have the same problem with the latest version.

Thanks

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

2 participants