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

datadog_service_definition_yaml plan crashes #2193

Closed
ZsoltPath opened this issue Nov 29, 2023 · 2 comments · Fixed by #2196
Closed

datadog_service_definition_yaml plan crashes #2193

ZsoltPath opened this issue Nov 29, 2023 · 2 comments · Fixed by #2196
Labels

Comments

@ZsoltPath
Copy link

Datadog Terraform Provider Version

v3.33.0

Terraform Version

v1.5.2

What resources or data sources are affected?

datadog_service_definition_yaml

Terraform Configuration Files

resource "datadog_service_definition_yaml" "auth-api" {
  service_definition = yamlencode(local.auth_api_service_definition)
}

locals {
  auth_api_service_definition = {
    schema-version = "v2.1"
    dd-service     = "auth-api"
    team           = "Pandas"
    contacts = [
      {
        name    = "Team Slack"
        type    = "slack"
        contact = "#pandas"
      }
    ]
    description = "Authentication service for MentorDigital"
    tier        = "high"
    lifecycle   = "production"
    application = "mentor"
    links = [
      {
        name = "GitHub repo"
        type = "repository"
        url  = "https://github.com/******/******/apps/auth-api"
      }
    ]
    tags = [
      { Environment = var.environment },
      { CostCenter = "Mentor" },
      { TFProject = "infra-mentor" },
      { BusinessUnit = "TBC" },
      { Confidentiality = "Internal" },
    ]
  }
}

Relevant debug or panic output

Stack trace from the terraform-provider-datadog_v3.33.0 plugin:

panic: interface conversion: interface {} is map[string]interface {}, not string

goroutine 157 [running]:
github.com/terraform-providers/terraform-provider-datadog/datadog.prepServiceDefinitionResource(0x140009fa6c0?)
github.com/terraform-providers/terraform-provider-datadog/datadog/resource_datadog_service_definition_yaml.go:147 +0x99c
github.com/terraform-providers/terraform-provider-datadog/datadog.resourceDatadogServiceDefinitionYAML.func2.1({0x104266ea0?, 0x14000a1b940?})
github.com/terraform-providers/terraform-provider-datadog/datadog/resource_datadog_service_definition_yaml.go:92 +0x44
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diffString(0x0?, {0x103e87f29, 0x12}, 0x140009ee500, 0x140005e8ae8, {0x1045b5e80, 0x140004f5100}, 0x0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:1549 +0xc0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diff(0x103e788ba?, {0x1045b1ec0, 0x14000968600}, {0x103e87f29, 0x12}, 0x140009ee500, 0x140004f5080, {0x1045b5e80?, 0x140004f5100}, 0x0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:1128 +0xe0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x14000968c30, {0x1045b1ec0, 0x14000968600}, 0x14000b7fd40, 0x14000968ba0, 0x1400007d000, {0x1041d5720, 0x140009a7a40}, 0x0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:678 +0x2a4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x140002eb0a0?, {0x1045b1ec0?, 0x14000968600?}, 0x14000b7fd40, 0x1042e77c0?, {0x1041d5720?, 0x140009a7a40?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:917 +0x9c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0x140002ffbd8, {0x1045b1ec0?, 0x14000968480?}, 0x140009a4690)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:744 +0x838
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.PlanResourceChange({0x14000211cb0, 0x14000211d10, {0x1400001bf40, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
github.com/hashicorp/[email protected]/tf5muxserver/mux_server_PlanResourceChange.go:27 +0xdc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0x1400019ff40, {0x1045b1ec0?, 0x140003b8c90?}, 0x14000a17960)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:786 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x1044d7960?, 0x1400019ff40}, {0x1045b1ec0, 0x140003b8c90}, 0x14000a178f0, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:404 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002c0000, {0x1045b74c0, 0x14000582680}, 0x14000f1a5a0, 0x14000125cb0, 0x1052703a8, 0x0)
google.golang.org/[email protected]/server.go:1335 +0xc90
google.golang.org/grpc.(*Server).handleStream(0x140002c0000, {0x1045b74c0, 0x14000582680}, 0x14000f1a5a0, 0x0)
google.golang.org/[email protected]/server.go:1712 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:947 +0xb4
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:958 +0x174

Error: The terraform-provider-datadog_v3.33.0 plugin crashed!

Expected Behavior

Resource creation planned

Actual Behavior

Error above

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@ZsoltPath ZsoltPath added the bug label Nov 29, 2023
@nkzou
Copy link
Contributor

nkzou commented Dec 1, 2023

What format are you trying to have your tags be encoded as? We can fix the panic but the problem is because your tags array is being yamlencoded as an array of maps instead of an array of strings.

    tags = [
      "Environment:${var.environment}",
      "CostCenter:Mentor",
      "TFProject:infra-mentor",
      "BusinessUnit:TBC",
      "Confidentiality:Internal",
    ]

using this snippet will apply successfully with key:value tags if that's what you're looking for.

@ZsoltPath
Copy link
Author

Hi @nkzou,

If that's the TF format, I'm happy with it. It's working fine now.

Although it still isn't nice to throw a panic for a format mismatch.

What format are you trying to have your tags be encoded as? We can fix the panic but the problem is because your tags array is being yamlencoded as an array of maps instead of an array of strings.

    tags = [
      "Environment:${var.environment}",
      "CostCenter:Mentor",
      "TFProject:infra-mentor",
      "BusinessUnit:TBC",
      "Confidentiality:Internal",
    ]

using this snippet will apply successfully with key:value tags if that's what you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants