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] invalid character 'A' looking for beginning of value #169

Closed
nikki603 opened this issue Mar 19, 2024 · 10 comments
Closed

[BUG] invalid character 'A' looking for beginning of value #169

nikki603 opened this issue Mar 19, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@nikki603
Copy link

What is the bug?

terraform apply returns

│ Error: invalid character 'A' looking for beginning of value
│ 
│   with opensearch_index.index1,
│   on opensearch.tf line 1, in resource "opensearch_index" "index1":
│    1: resource "opensearch_index" "index1" {

How can one reproduce the bug?

resource "opensearch_index" "index1" {
  name             = "index1"
  index_knn        = true
  default_pipeline = "my-pipeline-id"
  mappings         = <<EOF
{
    "properties": {
      "entity_name_v": {
        "type": "knn_vector",
        "dimension": 384,
        "method": {
          "name": "hnsw",
          "engine": "lucene",
          "space_type": "cosinesimil"
        }
      },
      "entity_name": {
        "type": "text" 
      }
    }
  }
EOF
}

Fails with this error when the provider is using the custom domain URL.

provider "opensearch" {
  url         = "https://search.mydomain.com"
  healthcheck = false
}

This custom domain is a CNAME record in Route53 with value of the AWS provided domain URL.

It does not fail when using the AWS provided domain URL.

provider "opensearch" {
  url         = "https://my-domain.us-east-1.es.amazonaws.com"
  healthcheck = false
}

terraform apply

What is the expected behavior?

index1 created successfully

What is your host/environment?

hashicorp/terraform:1.6.6 Docker container OR MacOS 14.1 (23B2073)
opensearch-project/opensearch provider 2.2.0
AWS OpenSearch version OpenSearch_2_11_R20231113-P4 (latest)

@nikki603 nikki603 added bug Something isn't working untriaged labels Mar 19, 2024
@rblcoder
Copy link
Collaborator

rblcoder commented Mar 20, 2024

@nikki603
Copy link
Author

@rblcoder Yes it's configured. I confirmed the custom URL works various ways like in browser to access the Dashboard, Postman requests, and Logstash output plugin.
Screenshot 2024-03-21 at 9 30 42 AM

@rblcoder
Copy link
Collaborator

rblcoder commented Mar 21, 2024

@nikki603 could you check if setting insecure to true helps in the OpenSearch terraform provider?

@nikki603
Copy link
Author

@rblcoder I still get the same error

Screenshot 2024-03-21 at 6 44 46 PM

@rblcoder
Copy link
Collaborator

@nikki603 What is the authentication mode you are using? Is it basic authentication or something else?

@nikki603
Copy link
Author

@rblcoder fine grain access control is enabled so I'm using IAM auth. I'm using AWS SSO locally. When running from a CI/CD pipeline I will be using the aws_access_key, aws_secret_key, and aws_token params.

@rblcoder
Copy link
Collaborator

rblcoder commented Mar 25, 2024

@nikki603 I am able apply the following terraform code, I have defined a custom endpoint for my AWS OpenSearch Service domain.

terraform {
  required_providers {
    opensearch = {
      source = "opensearch-project/opensearch"
      version = "2.2.0"
    }
  }
}

provider "opensearch" {
  url = "https://customsubdomain.domain.tld"
  healthcheck        = "false"
  aws_region          = "region"
  
  version_ping_timeout = "10"

}

resource "opensearch_index" "index" {
  name = "sample"
  number_of_replicas = "1"
  number_of_shards = "1"
}

@rblcoder
Copy link
Collaborator

rblcoder commented Mar 27, 2024

@nikki603 I tested both modifying an existing AWS OpenSearch domain and specifying a custom endpoint at the time of creation of the domain, both are working.

@nikki603
Copy link
Author

I see that I was missing aws_region = "region" when using a custom domain. It works now. Thanks for the attention!

@rblcoder
Copy link
Collaborator

Great, good to hear it works now!

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

No branches or pull requests

2 participants