dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
71 stars 33 forks source link

`Could not map JSON at 'supportingServicesToMonitor[0].monitoredMetrics[0].statistic'` in `dynatrace_aws_credentials` modules #357

Closed EthanZmuda closed 11 months ago

EthanZmuda commented 1 year ago

Describe the bug We are getting the error described in the title when trying to run deploys. This error is happening on settings unrelated to our changes which have previously deployed successfully. Here is the full error:

│ Error: Could not map JSON at 'supportingServicesToMonitor[0].monitoredMetrics[0].statistic' near line 1 column 287
│ 
│   with module.production_settings[0].module.aws_credentials.dynatrace_aws_credentials.cobra-prod,
│   on production/settings/aws_credentials/cobra-prod.tf line 1, in resource "dynatrace_aws_credentials" "cobra-prod":
│    1: resource "dynatrace_aws_credentials" "cobra-prod" {

This error is inconsistently happening on many dynatrace_aws_credentials modules. Sometimes when redeploying the error resolves on some modules and starts occurring on others. Here is an example of one such module:

resource "dynatrace_aws_credentials" "cobra-prod" {
  label          = "cobra-prod - TF managed"
  partition_type = "AWS_CN"
  tagged_only    = false
  authentication_data {
    account_id = "***" # I'm not sure if the account ID is sensitive so I'm censoring it
    iam_role   = "SFGBaselineDynatraceMonitoring"
  }
  supporting_services_to_monitor {
    name = "fsx"
  }
}

This error is especially odd because this module doesn't have a .monitoredMetrics[0].statistic attribute (nor do any of our modules throwing this error), yet the error is saying the issue is with that attribute. According to the documentation, this attribute is not required. Adding this attribute does not necessarily resolve the error.

Expected behavior Successful deploys, with no inconsistent error due to an attribute in our modules which doesn't exist.

Desktop (please complete the following information):

Additional context This issue began occurring during deploys today. Our most recent successful deploy used version v1.46.0.

EthanZmuda commented 1 year ago

Just did some more testing and found that we can successfully deploy on v1.46.0, so I'm guessing this must be an issue with v1.46.1.

Dynatrace-Reinhard-Pilz commented 11 months ago

Hello @EthanZmuda , thanks for reporting the issue. Root cause here is like in #360 the known bug in the plugin-sdk.

What I cannot find a satisfying answer for is the question why a rollback to a specific other version leads to the problem to emerge less likely. I've checked our GitHub history - dynatrace_aws_credentials hasn't been touched for a while now. Changes between release 1.46.0 and 1.46.1 contained solely a fix for Dashboards and nothing else.

Release 1.47.1 will contain routines that are able to recognize erroneously empty blocks for this resource and ignore them.

Dynatrace-Reinhard-Pilz commented 11 months ago

Hello @EthanZmuda, let me know if v1.47.1 indeed fixes your issues. Reproducing the problem is unfortunately a hit and miss, therefore I'd be grateful for feedback from your side.

EthanZmuda commented 11 months ago

@Dynatrace-Reinhard-Pilz Thanks! I'll let you know if it's working better next time we make changes in the repo.