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

TERRA-81 ⁃ json: cannot unmarshal string into Go value of type astra.Errors #174

Closed
alex4423 opened this issue Oct 26, 2022 · 27 comments
Closed

Comments

@alex4423
Copy link

alex4423 commented Oct 26, 2022

Hi there,

I have the following error message for 2 days (was working fine before)
json: cannot unmarshal string into Go value of type astra.Errors

Version:
Terraform v1.3.3
datastax/astra v2.1.6 (i tried older versions)

I removed every resources, just kept the provider and still have the issue:

terraform {
  required_providers {
    astra = {
      source  = "datastax/astra"
    }
  }
}

provider "astra" {
  token = var.astra_provider_token
}

It is a blocker to manage multiple DB's

┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: TERRA-81
┆priority: Major

@sync-by-unito sync-by-unito bot changed the title json: cannot unmarshal string into Go value of type astra.Errors TERRA-81 ⁃ json: cannot unmarshal string into Go value of type astra.Errors Oct 26, 2022
@emerkle826
Copy link
Contributor

@alex4423 Thanks for filing an issue. However, I may need a little more info. The example terraform file you provided doesn't really do anything, and if I try to reproduce the issue with just that, I am unable to. Using the provided config, the plugin would simply be downloaded and terraform would initialize its state, and that works with just about any version of the provider.

Do you have more details on what was in your config when you started seeing the error? There may be something in your tfstate file locally that needs to be updated, but I can't tell what that might be.

@alex4423
Copy link
Author

sure, here my full Astra config (there are son GCP parts for private links as well but following the message error, I will avoid it)

# Astra Provider
terraform {
  required_providers {
    astra = {
      source = "datastax/astra"
    }
  }
}

provider "astra" {
  token = var.astra_provider_token
}

# Astra DB
resource "astra_database" "db" {
  count          = var.astra_db_number
  name           = "${var.namespace}-db-${count.index + 1}"
  keyspace       = "default"
  cloud_provider = "gcp"
  regions        = ["${var.region}"]

}

# Astra Private Link
resource "astra_private_link" "db" {
  count              = var.astra_db_number
  allowed_principals = ["${var.project}"]
  database_id        = astra_database.db[count.index].id
  datacenter_id      = "${astra_database.db[count.index].id}-1"

  depends_on = [astra_database.db]
}

resource "astra_private_link_endpoint" "db" {
  count         = var.astra_db_number
  database_id   = astra_database.db[count.index].id
  datacenter_id = "${astra_database.db[count.index].id}-1"
  endpoint_id   = google_compute_forwarding_rule.astra_db[count.index].psc_connection_id
}

resource "astra_access_list" "db" {
  count       = var.astra_db_number
  database_id = astra_database.db[count.index].id
  enabled     = true
  addresses {
    address = var.vpc_cidr
    enabled = true
  }
}

NOTE:
I just tried to build DB's on a brand new Organization and I didn't have the error. So apparently, it is just on existing Organizations (where I built multiples DB's in the past with this terraform config...I have the error on 15 Org.).

@emerkle826
Copy link
Contributor

@alex4423 Thanks again.

Few more questions.

  1. Are you using the same Astra Token for the new org as well as the orgs where things are broken?
  2. For an organization where things are broken, are you completely unable to create a new DB?
  3. For an organization where things are broken, can you destroy any resources (i.e. deete a Database or access list, etc.)?

@alex4423
Copy link
Author

alex4423 commented Oct 26, 2022

I have an Admin User Token per Organization (all different...15 in total...I tried to create a new one but same issue)
Terraform is not able to read anything in Organizations, I have the message as soon as it is trying to reach Astra (so can't read, build or destroy).
I removed all my modules and just kept the Astra Provider config (like the original message I sent you) and still have the error.

@emerkle826
Copy link
Contributor

Can you try to generate a new Admin token for one of the orgs that is broken and use that to see if it fixes things with Terraform?

@alex4423
Copy link
Author

alex4423 commented Oct 26, 2022

I already tried and have the same issue
and just tried another one just in case...same problem

I run a "plan" and grep astra
Terraform seems able to refresh states on Astra modules I am using.
So I was probably wrong, the Token is working ? maybe not able to complete refresh ?

I am thinking to delete states and reimport but that would be a huge work for me

@emerkle826
Copy link
Contributor

Can you capture the DEBUG logs for a command that fails?

TF_LOG=DEBUG terraform apply

should produce enough. I just need to see the calls it's making when it gets an error. Then I can figure out what to fix so the error isn't generic, and then we can figure out what's really wrong and how to fix it.

@alex4423
Copy link
Author

sure
I run TF_LOG=DEBUG terraform plan -refresh-only

Here logs:

2022-10-26T16:36:07.202-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2022-10-26T16:36:07.206-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/4.41.0/darwin_amd64/terraform-provider-google_v4.41.0_x5 pid=71658
2022-10-26T16:36:07.206-0400 [DEBUG] provider: plugin exited
2022-10-26T16:36:07.326-0400 [INFO]  backend/local: plan operation completed
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
╷
│ Error: json: cannot unmarshal string into Go value of type astra.Errors
│
│
╵
2022-10-26T16:36:07.545-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2022-10-26T16:36:07.547-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/datastax/astra/2.1.6/darwin_amd64/terraform-provider-astra_v2.1.6 pid=71659
2022-10-26T16:36:07.547-0400 [DEBUG] provider: plugin exited

@emerkle826
Copy link
Contributor

This is very strange. So locally, I tried the same and I see this:

2022-10-26T15:46:14.097-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2022-10-26T15:46:14.098-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/datastax/astra/2.1.6/linux_amd64/terraform-provider-astra_v2.1.6 pid=2821592
2022-10-26T15:46:14.098-0500 [DEBUG] provider: plugin exited
2022-10-26T15:46:14.098-0500 [DEBUG] Building and walking validate graph

then a little later in the logs:

2022-10-26T15:46:14.661-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2022-10-26T15:46:14.663-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/datastax/astra/2.1.6/linux_amd64/terraform-provider-astra_v2.1.6 pid=2821605
2022-10-26T15:46:14.664-0500 [DEBUG] provider: plugin exited
2022-10-26T15:46:14.664-0500 [DEBUG] building apply graph to check for errors
2022-10-26T15:46:14.664-0500 [DEBUG] ProviderTransformer: "astra_database.terra81 (destroy)" (*terraform.NodeDestroyResourceInstance) needs provider["registry.terraform.io/datastax/astra"]
2022-10-26T15:46:14.665-0500 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/datastax/astra\"]" references: []
2022-10-26T15:46:14.665-0500 [INFO]  backend/local: plan operation completed

Are there any GET or POST logs when you run the plan? Something like this:

2022-10-26T15:46:14.157-0500 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 15:46:14 [DEBUG] GET https://api.astra.datastax.com/v2/databases/c23921de-5f19-484e-886a-be09c5dfef29

The astra.Errors thing only comes into play when the provider tries to make a REST call to the Astra DevOps API. I'm not seeing any endpoints called, so I don't know which one is failing. I assume it's the databases call like I've showed.

@alex4423
Copy link
Author

that will be hard to say. I am managing almost everything with Terraform so I have a lot of modules running...the DEBUG output is huge.
do you know if we can run a "plan" only a on specific provider ?

@emerkle826
Copy link
Contributor

Can you run a plan with just TF_LOG_PROVIDER=DEBUG, or is that still going to be a huge log?

@alex4423
Copy link
Author

still huge but I run with TF_LOG_PROVIDER=ERROR
hope that can help

2022-10-26T19:01:33.393-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" tf_provider_addr=provider tf_req_id=e3dd3d92-8e7d-f0ca-f85d-7d8608496397 @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto tf_rpc=ReadResource tf_resource_type=astra_access_list tf_proto_version=5.3 timestamp=2022-10-26T19:01:33.393-0400

2022-10-26T19:01:33.443-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: tf_provider_addr=provider diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" tf_proto_version=5.3 tf_req_id=ea941ae6-d544-70db-d0b0-d35b9ce2248f @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto tf_resource_type=astra_access_list tf_rpc=ReadResource timestamp=2022-10-26T19:01:33.442-0400

2022-10-26T19:01:33.465-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: tf_provider_addr=provider tf_req_id=e5fb9ad0-5cb8-89d0-ac67-e4f55171bf71 tf_resource_type=astra_access_list tf_rpc=ReadResource tf_proto_version=5.3 diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto diagnostic_detail= diagnostic_severity=ERROR timestamp=2022-10-26T19:01:33.465-0400

2022-10-26T19:01:33.642-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: tf_provider_addr=provider tf_resource_type=astra_access_list @module=sdk.proto diagnostic_severity=ERROR tf_rpc=ReadResource @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_detail= diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" tf_proto_version=5.3 tf_req_id=7071d073-fd61-c0b5-98dc-57f0993ddab5 timestamp=2022-10-26T19:01:33.642-0400
2022-10-26T19:01:33.673-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: diagnostic_detail= diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" tf_rpc=ReadResource @module=sdk.proto diagnostic_severity=ERROR tf_proto_version=5.3 tf_provider_addr=provider tf_req_id=2b2d82ab-8931-5065-cfc6-640a58b3987b tf_resource_type=astra_access_list @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 timestamp=2022-10-26T19:01:33.673-0400
2022-10-26T19:01:33.687-0400 [ERROR] provider.terraform-provider-astra_v2.1.6: Response contains error diagnostic: diagnostic_detail= diagnostic_severity=ERROR tf_provider_addr=provider tf_resource_type=astra_access_list tf_rpc=ReadResource @module=sdk.proto diagnostic_summary="json: cannot unmarshal string into Go value of type astra.Errors" tf_proto_version=5.3 tf_req_id=5c87dd60-2eca-5650-d28f-1c31bb666d0f @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 timestamp=2022-10-26T19:01:33.687-0400

@alex4423
Copy link
Author

I finally found how to push that to a log file, here output with more details

with GET:

2022-10-26T19:16:00.269-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4
2022-10-26T19:16:00.269-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/a021a93e-742b-49ef-b765-60cebc902899
2022-10-26T19:16:00.272-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/ef7a056a-a427-4f9c-9276-a99bff9d4786
2022-10-26T19:16:00.359-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/dc68176e-d6de-4187-8cd0-39833011e7be
2022-10-26T19:16:00.367-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/63d84d0d-477c-4455-8c3e-820a6e24dd93
2022-10-26T19:16:00.413-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/41eca937-8483-4cf1-8507-84e7914de8ed
2022-10-26T19:16:00.541-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/a021a93e-742b-49ef-b765-60cebc902899/access-list
2022-10-26T19:16:00.544-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4/access-list
2022-10-26T19:16:00.548-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/ef7a056a-a427-4f9c-9276-a99bff9d4786/access-list
2022-10-26T19:16:00.559-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/41eca937-8483-4cf1-8507-84e7914de8ed
2022-10-26T19:16:00.572-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/ef7a056a-a427-4f9c-9276-a99bff9d4786
2022-10-26T19:16:00.613-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/a021a93e-742b-49ef-b765-60cebc902899
2022-10-26T19:16:00.622-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/41eca937-8483-4cf1-8507-84e7914de8ed/access-list
2022-10-26T19:16:00.625-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/dc68176e-d6de-4187-8cd0-39833011e7be/access-list
2022-10-26T19:16:00.627-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/63d84d0d-477c-4455-8c3e-820a6e24dd93/access-list
2022-10-26T19:16:00.635-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/63d84d0d-477c-4455-8c3e-820a6e24dd93
2022-10-26T19:16:00.637-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4
2022-10-26T19:16:00.684-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:00 [DEBUG] GET https://api.astra.datastax.com/v2/databases/dc68176e-d6de-4187-8cd0-39833011e7be
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-3?alt=json HTTP/1.1
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-4?alt=json HTTP/1.1
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-6?alt=json HTTP/1.1
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-1?alt=json HTTP/1.1
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-2?alt=json HTTP/1.1
GET /v1/projects/workjam-production/secrets/uat-usa-2-gcp-common-astra-db-5?alt=json HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra?alt=json&prettyPrint=false HTTP/1.1
2022-10-26T19:16:01.570-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/ef7a056a-a427-4f9c-9276-a99bff9d4786
2022-10-26T19:16:01.593-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/a021a93e-742b-49ef-b765-60cebc902899
2022-10-26T19:16:01.595-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4
2022-10-26T19:16:01.610-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/63d84d0d-477c-4455-8c3e-820a6e24dd93
2022-10-26T19:16:01.651-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/41eca937-8483-4cf1-8507-84e7914de8ed
2022-10-26T19:16:01.654-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/ef7a056a-a427-4f9c-9276-a99bff9d4786/datacenters/ef7a056a-a427-4f9c-9276-a99bff9d4786-1/private-link
2022-10-26T19:16:01.665-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/databases/dc68176e-d6de-4187-8cd0-39833011e7be
2022-10-26T19:16:01.675-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4/datacenters/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4-1/private-link
2022-10-26T19:16:01.689-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/a021a93e-742b-49ef-b765-60cebc902899/datacenters/a021a93e-742b-49ef-b765-60cebc902899-1/private-link
2022-10-26T19:16:01.696-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/63d84d0d-477c-4455-8c3e-820a6e24dd93/datacenters/63d84d0d-477c-4455-8c3e-820a6e24dd93-1/private-link
2022-10-26T19:16:01.740-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/41eca937-8483-4cf1-8507-84e7914de8ed/datacenters/41eca937-8483-4cf1-8507-84e7914de8ed-1/private-link
2022-10-26T19:16:01.744-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:01 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/dc68176e-d6de-4187-8cd0-39833011e7be/datacenters/dc68176e-d6de-4187-8cd0-39833011e7be-1/private-link
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-1-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-4-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-5-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-3-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-6-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/addresses/uat-usa-2-gcp-common-astra-db-2-private-ip?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-6-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-6-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-2-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-2-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-3-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-3-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-1-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-1-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-4-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-4-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-5-private-service-connect?alt=json HTTP/1.1
GET /compute/beta/projects/workjam-production/regions/us-central1/forwardingRules/uat-usa-2-gcp-common-astra-db-5-private-service-connect?alt=json HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=63d84d0d-477c-4455-8c3e-820a6e24dd93-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=ef7a056a-a427-4f9c-9276-a99bff9d4786-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=a021a93e-742b-49ef-b765-60cebc902899-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=155fc2bc-6844-4ba6-8ce0-e51b019d5bb4-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=41eca937-8483-4cf1-8507-84e7914de8ed-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=dc68176e-d6de-4187-8cd0-39833011e7be-us-central1.db.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=41eca937-8483-4cf1-8507-84e7914de8ed-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=ef7a056a-a427-4f9c-9276-a99bff9d4786-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=a021a93e-742b-49ef-b765-60cebc902899-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=63d84d0d-477c-4455-8c3e-820a6e24dd93-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=155fc2bc-6844-4ba6-8ce0-e51b019d5bb4-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
GET /dns/v1/projects/workjam-production/managedZones/astra/rrsets?alt=json&name=dc68176e-d6de-4187-8cd0-39833011e7be-us-central1.apps.astra.datastax.com.&prettyPrint=false&type=A HTTP/1.1
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
  "target": "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/beta/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
 Target: "https://www.googleapis.com/compute/v1/projects/astra-serverless-prod-44/regions/us-central1/serviceAttachments/pl-prod",
2022-10-26T19:16:04.101-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/ef7a056a-a427-4f9c-9276-a99bff9d4786
2022-10-26T19:16:04.104-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/a021a93e-742b-49ef-b765-60cebc902899
2022-10-26T19:16:04.127-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/63d84d0d-477c-4455-8c3e-820a6e24dd93
2022-10-26T19:16:04.130-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/41eca937-8483-4cf1-8507-84e7914de8ed
2022-10-26T19:16:04.154-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4
2022-10-26T19:16:04.176-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/ef7a056a-a427-4f9c-9276-a99bff9d4786/datacenters/ef7a056a-a427-4f9c-9276-a99bff9d4786-1/endpoints/8699997597597806
2022-10-26T19:16:04.179-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/databases/dc68176e-d6de-4187-8cd0-39833011e7be
2022-10-26T19:16:04.183-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/a021a93e-742b-49ef-b765-60cebc902899/datacenters/a021a93e-742b-49ef-b765-60cebc902899-1/endpoints/8699997597597701
2022-10-26T19:16:04.201-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/63d84d0d-477c-4455-8c3e-820a6e24dd93/datacenters/63d84d0d-477c-4455-8c3e-820a6e24dd93-1/endpoints/8699997597597771
2022-10-26T19:16:04.213-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/41eca937-8483-4cf1-8507-84e7914de8ed/datacenters/41eca937-8483-4cf1-8507-84e7914de8ed-1/endpoints/8699997597597808
2022-10-26T19:16:04.227-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4/datacenters/155fc2bc-6844-4ba6-8ce0-e51b019d5bb4-1/endpoints/8699997597597723
2022-10-26T19:16:04.253-0400 [DEBUG] provider.terraform-provider-astra_v2.1.6: 2022/10/26 19:16:04 [DEBUG] GET https://api.astra.datastax.com/v2/organizations/clusters/dc68176e-d6de-4187-8cd0-39833011e7be/datacenters/dc68176e-d6de-4187-8cd0-39833011e7be-1/endpoints/8699997597597807

@alex4423
Copy link
Author

Good news
the problem is coming from the module astra_access_list
I deleted the state terraform state rm module.astra.astra_access_list.db and I didn't have the issue after a "plan"

@emerkle826
Copy link
Contributor

@alex4423 Thanks for the updates.

I can look into the astra_access_list resource operations to fix the Error message. I am curious if you are able to re-import your access list into the state?

@alex4423
Copy link
Author

I put back the module
here the error message I received
│ Error: error adding access list to database: (403) "user hPCrurTuPtEBJkjYdtZClepA is missing admin role for organization bf2ba0d8-c9a0-4332-ac51-d6292daee7f5"

@emerkle826
Copy link
Contributor

Thanks again for the update @alex4423 .

That's the kind of information you should see if something goes wrong as you can at least tell what is wrong. But what I'm still not sure of is what caused the json: cannot unmarshal string into Go value of type astra.Errors. When you see that, it means that the provider had an problem interacting with the Astra DevOps API, but the response was not JSON formatted and the provider was expecting the response to be JSON. If I know which call resulted in that error, I can usually fix it pretty quickly, but without knowing what REST call was made, it's hard to find the one that is broken in the error response parsing.

I'll take a look at the access_list operations and see if I can find one that is broken on errors.

@alex4423
Copy link
Author

alex4423 commented Oct 28, 2022

I understand.
Sorry I can't give you more. I don't really have more time to spend on this one...sorry.
I am unblocked so it is less urgent for me.

At one point, I will have to put back this module. If you didn't find the issue, hopefully, I'll be able to help

@emerkle826
Copy link
Contributor

I am unblocked so it is less urgent for me.

I am glad you are unblocked. I'll keep digging, so I'll leave this ticket open for now.

At one point, I will have to put back this module.

From the error you posted about trying to add the access_list back, it seems the token in use does not have enough permissions:
│ Error: error adding access list to database: (403) "user hPCrurTuPtEBJkjYdtZClepA is missing admin role for organization bf2ba0d8-c9a0-4332-ac51-d6292daee7f5"

Are you using a token associated with a custom Role that you created, or one associated with the preset Administrator Roles? There is a bug with some Admin operations when using a custom role, even if the role has all admin permissions. (See this comment here and the discussion in that ticket).

If this ends up being a DevOps API issue, I'll have to get back to the team that manages that and escalate this.

@alex4423
Copy link
Author

no, not custom. the token is for Admin User

@emerkle826
Copy link
Contributor

@alex4423 Small update. I can only seem to produce the error you are getting:

Error: error adding access list to database: (403) "user hPCrurTuPtEBJkjYdtZClepA is missing admin role for organization bf2ba0d8-c9a0-4332-ac51-d6292daee7f5"

when I use a token that is associated with a role that doesn't have access list write permissions. I created a custom role that simply had these permissions:

   "policy" : {
      "actions" : [
         "accesslist-write",
         "accesslist-read",
         "org-db-view"
      ],

and I am able to add access lists to my Astra DB. When I remove accesslist-write, and only have:

   "policy" : {
      "actions" : [
         "accesslist-read",
         "org-db-view"
      ],

I get the 403 error.

Can you double check that Terraform is using a token with sufficient privileges?

@alex4423
Copy link
Author

alex4423 commented Nov 1, 2022

hello.
Sorry, I didn't see your message.
only tokens I have and use are for Admin Users from the beginning. Does that mean they are not good anymore ?
I didn't have this original issue for a long time with those Tokens..everything was ok.

@emerkle826
Copy link
Contributor

Does that mean they are not good anymore ?

Unless the permissions were changed for the role, they should still be good. Can you try creating a new token with the Organization Admin role and use that token to see if you still get a 403?

@alex4423
Copy link
Author

with Admin User, I have a 403
error adding access list to database: (403) "user XXXXX is missing admin role for organization

with Organization Admin, I have a 409
error adding access list to database: (409) "unable to add address to access list"

@emerkle826
Copy link
Contributor

@alex4423 The Admin User role does not have the accesslist-write permission, so using a token with that role should get a 403 when trying to create/modify/delete access lists. The only 2 baked-in roles that have the accesslist-write permission are Organization Administrator and Database Administrator

The 409 you are getting when you use an Organization Administrator token is likely because the access list has already been created. In this case, you can either delete the access list entries from the UI and try again with terraform, or you can try to do a terraform import to import the access list that already exists into your terraform state.

@alex4423
Copy link
Author

I still have 409 when I removed the Access list and run terraform afterwards

@pgier
Copy link
Collaborator

pgier commented Sep 1, 2023

This should be fixed by #298, at least the error should now be displayed appropriately back to the user.

@pgier pgier closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants