dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
68 stars 33 forks source link

terraform-provider-dynatrace -export generates corrupted "dynatrace_oneagent_updates" resource when the update mode is AUTOMATIC_DURING_MW #521

Closed davidghughes closed 2 weeks ago

davidghughes commented 2 weeks ago

Describe the bug Running (the latest version (1.65.0)) of terraform-provider-dynatrace:

./terraform-provider-dynatrace -export -id -ref 

against just one of our Dynatrace tenancies consistently produces incorrect output where the other tenancies do not. The only difference between the successful and this one is that the update_mode = "AUTOMATIC_DURING_MW" (as far as I can ascertain)

To Reproduce Steps to reproduce the behavior: Run ./terraform-provider-dynatrace -export -id -ref

resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXXXXXXXXXXXXX" {
  scope          = "" {
  scope          = "HOST_GROUP-XXXXXXXXXXXXXXXX"
  target_version = "previous"
  update_mode    = "AUTOMATIC_DURING_MW"
  maintenance_windows {
    maintenance_window {
      maintenance_window = "${var.dynatrace_update_windows.FOO.id}"
    }
  }
}
"
  target_version = "previous"
  update_mode    = "AUTOMATIC_DURING_MW"
  maintenance_windows {
    maintenance_window {
      maintenance_window = "${var.dynatrace_update_windows.FOO.id}"
    }
  }
}

Expected behavior I would expect the correctly formatted terraform

resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXXXXXXXXXXXXX" {
  scope          = "HOST_GROUP-XXXXXXXXXXXXXXXX"
  target_version = "previous"
  update_mode    = "AUTOMATIC_DURING_MW"
  maintenance_windows {
    maintenance_window {
      maintenance_window = "${var.dynatrace_update_windows.FOO.id}"
    }
  }
}

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

This has been confirmed to be an issue with terraform-provider-dynatrace versions 1.62.0 up to 1.65.0

Output from the terraform fmt applied to the output:

│ Error: Missing newline after argument
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 3, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│    3:   scope          = "" {
│ 
│ An argument definition must end with a newline.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 13, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   13: "
│   14:   target_version = "previous"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 14, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   14:   target_version = "previous"
│   15:   update_mode    = "AUTOMATIC_DURING_MW"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 15, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   15:   update_mode    = "AUTOMATIC_DURING_MW"
│   16:   maintenance_windows {
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 16, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   16:   maintenance_windows {
│   17:     maintenance_window {
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 17, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   17:     maintenance_window {
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid character
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 18, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│ 
│ This character is not used within the language.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 18, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│   19:     }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 19, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   19:     }
│   20:   }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 20, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   20:   }
│   21: }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 21, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   21: }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Missing newline after argument
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 3, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│    3:   scope          = "" {
│ 
│ An argument definition must end with a newline.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 13, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   13: "
│   14:   target_version = "previous"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 14, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   14:   target_version = "previous"
│   15:   update_mode    = "AUTOMATIC_DURING_MW"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 15, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   15:   update_mode    = "AUTOMATIC_DURING_MW"
│   16:   maintenance_windows {
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 16, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   16:   maintenance_windows {
│   17:     maintenance_window {
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 17, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   17:     maintenance_window {
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid character
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 18, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│ 
│ This character is not used within the language.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 18, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   18:       maintenance_window = "${var.dynatrace_update_windows.ABCD.id}"
│   19:     }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 19, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   19:     }
│   20:   }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 20, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   20:   }
│   21: }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

╷
│ Error: Invalid multi-line string
│ 
│   on Dynatrace/terraform/prod/modules/oneagent_updates/HOST_GROUP-XXXXYYYYXXXXZZZZ.oneagent_updates.tf line 21, in resource "dynatrace_oneagent_updates" "HOST_GROUP-XXXXYYYYXXXXZZZZ":
│   21: }
│ 
│ Quoted strings may not be split over multiple lines. To produce a
│ multi-line string, either use the \n escape to represent a newline
│ character or use the "heredoc" multi-line template syntax.
╵

Error: Process completed with exit code 2.
Reinhard-Pilz-Dynatrace commented 2 weeks ago

Hi @davidghughes, you've unfortunately stumbled across a nasty regression bug here. Thanks for reporting. It will be fixed with the upcoming release of the provider.

regards, Reinhard

davidghughes commented 1 week ago

Can confirm that the issue is resolved in 1.66.0 Thanks.