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: can not marshal to path in request for field ConfigId. Due to can not marshal a nil pointer #2166

Open
RizwaanShaik opened this issue Jul 31, 2024 · 7 comments
Labels
bug In-Progress Terraform Team is working on the reproduce & fix

Comments

@RizwaanShaik
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version and Provider Version

Terraform v1.9.3
on linux_amd64

  • provider registry.terraform.io/hashicorp/external v2.3.3
  • provider registry.terraform.io/hashicorp/oci v6.4.0

Affected Resource(s)

Data Source: oci_apm_config_config

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. 
# Please remove any sensitive information from configuration files before sharing them. 
provider "oci" {
  config_file_profile = "DEFAULT"
}

data "oci_apm_config_config" "test_config" {
  apm_domain_id = "ocid1.apmdomain.oc1.iad.xxxxxxx"
  config_id     = "ocid1.apmconfig.oc1.iad.xxxxxxx"
}

output "final" {
  value = data.oci_apm_config_config.test_config
}

Debug Output

Panic Output

Expected Behavior

Output with current configuration of the apm_config, in this case Apdex Thresholds

Actual Behavior

Erroring out when taking in the paramter of ConfigId

Steps to Reproduce

  1. terraform plan

Important Factoids

References

Similar to the issue:
#1726

@tf-oci-pub tf-oci-pub added the In-Progress Terraform Team is working on the reproduce & fix label Aug 1, 2024
@tf-oci-pub
Copy link
Member

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

@iliassox
Copy link

The config_id is using the wring format. It should be something like configs/ocid1.apmconfig.oc1.iad.xxxxxxx/apmDomainId/ocid1.apmdomain.oc1.iad.xxxxxxx. Or you can use the variables, like in the official example after creating the resource: https://registry.terraform.io/providers/oracle/oci/latest/docs/data-sources/apm_config_config

@RizwaanShaik
Copy link
Author

RizwaanShaik commented Aug 21, 2024

Thank you for the response @iliassox

This is the Json Response I fetched using API from the browser where it does a GET call to fetch Apdex Thresholds from where I was able to extract the configId and the display name as you cannot access them directly from the OCI console.

  "items" : [ {
    "configType" : "APDEX",
    "id" : "ocid1.apmconfig.oc1.iad.aaaaaaaamaqh333xd6yjf4uzkerg33ipt4tajonwzgqyvosoohkbyta",
    "timeCreated" : "2023-10-18T13:29:43.159Z",
    "timeUpdated" : "2023-10-18T13:29:43.159Z",
    "createdBy" : null,
    "updatedBy" : null,
    "etag" : "4d7f50e601e21a0b1a4101e6bf15dd003606111717d04c474bba19deabd5a425",
    "freeformTags" : { },
    "definedTags" : { },
    "rules" : [ {
      "filterText" : "Component='BROWSER' AND ApmrumType='Page'",
      "priority" : 0,
      "isEnabled" : true,
      "satisfiedResponseTime" : 2000,
      "toleratingResponseTime" : 6000,
      "isApplyToErrorSpans" : false,
      "displayName" : "Page Loads"
    }, {
      "filterText" : "Component='BROWSER' AND ApmrumPageUpdateType='Full Update'",
      "priority" : 1,
      "isEnabled" : true,
      "satisfiedResponseTime" : 1500,
      "toleratingResponseTime" : 4500,
      "isApplyToErrorSpans" : false,
      "displayName" : "Full Page Updates"
    }, {
      "filterText" : "Component='BROWSER' AND ApmrumPageUpdateType='Partial Update'",
      "priority" : 2,
      "isEnabled" : true,
      "satisfiedResponseTime" : 1000,
      "toleratingResponseTime" : 3000,
      "isApplyToErrorSpans" : false,
      "displayName" : "Partial Page Updates"
    }, {
      "filterText" : "Component='BROWSER' AND ApmrumType='Ajax'",
      "priority" : 3,
      "isEnabled" : true,
      "satisfiedResponseTime" : 500,
      "toleratingResponseTime" : 1500,
      "isApplyToErrorSpans" : false,
      "displayName" : "Ajax Calls"
    }, {
      "filterText" : "kind='SERVER'",
      "priority" : 4,
      "isEnabled" : true,
      "satisfiedResponseTime" : 500,
      "toleratingResponseTime" : 2000,
      "isApplyToErrorSpans" : false,
      "displayName" : "Server Requests"
    } ],
    "displayName" : "Apdex Rules"
  } ]
}

And this issue is specific only to Apdex Thresholds, I am able to use terraform for other apmconfig resources like Span Enrichments, Span Filters, Custom Metrics without any issues.

And I'm also able to fetch the same data using OCI_CLI

Note: I have truncated a few characters in the value of id for security reasons

@iliassox
Copy link

Can you try changing your terraform file to have something like this:

...
data "oci_apm_config_config" "test_config" {
  apm_domain_id = "ocid1.apmdomain.oc1.iad.xxxxxxx"
  config_id     = "configs/ocid1.apmconfig.oc1.iad.xxxxxxx/apmDomainId/ocid1.apmdomain.oc1.iad.xxxxxxx"
}
...

Where ocid1.apmdomain.oc1.iad.xxxxxxx is the domain id to which the config belongs.

I was able to reproduce the issue, and this change seems to have worked!

@iliassox
Copy link

You can also use a script that creates the config and you use the values from the created resources which also works:

resource "oci_apm_config_config" "test_apdex" {
  #Required
  apm_domain_id = oci_apm_apm_domain.test_apm_domain.id
  config_type   = "APDEX"
  display_name  = "configDisplayName"

  rules {
      display_name = var.rule_display_name
      filter_text = var.rule_filter_text
      is_apply_to_error_spans = var.rule_is_apply_to_error_spans
      is_enabled = var.rule_is_enabled
      priority = var.rule_priority
      satisfied_response_time = var.rule_satisfied_response_time 
      tolerating_response_time = var.rule_tolerating_response_time 
  }
}

data "oci_apm_config_config" "test_config" {
  apm_domain_id = oci_apm_apm_domain.test_apm_domain.id
  config_id = oci_apm_config_config.test_apdex.id
}

This is from this documentation

@RizwaanShaik
Copy link
Author

Thanks a lot @iliassox. After trying out the change you suggested, I was able to get the data as output. I actually never came across the format of the configIds in any documentation
I'll have to modify my code to match this change.
Thank you.
Closing this issue.

@RizwaanShaik
Copy link
Author

Hi @iliassox, our primary objective was to automate the creation and updating of Apdex Threshold configurations using Terraform. However, we’ve encountered a limitation in OCI where the Apdex ruleset is a singleton and must always be present, causing issues with Terraform as it attempts to create the resource on the first run. Is there a workaround for this? Perhaps by creating a dummy tfstate file to bypass the initial run, or by directly calling the update Apdex API instead of the create API?

@RizwaanShaik RizwaanShaik reopened this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug In-Progress Terraform Team is working on the reproduce & fix
Projects
None yet
Development

No branches or pull requests

3 participants