terraform-provider-flux icon indicating copy to clipboard operation
terraform-provider-flux copied to clipboard

Conditional exec plugin statement fails execution

Open gberenice opened this issue 11 months ago • 0 comments

Hey!

We're building a reusable module and trying to support multiple Kubernetes authentication methods based on user's preferences. This includes the exec plugin. Currently the provider configuration for the exec plugin looks like this:

    exec = {
      api_version = "client.authentication.k8s.io/v1beta1"
      command     = "aws"
      args = concat(local.exec_profile, [
        "eks", "get-token", "--cluster-name", var.eks_cluster_name
      ], local.exec_role)
    }

When we add a conditional statement like

exec = local.kube_exec_auth_enabled && length(local.cluster_ca_certificate) > 0 ? { <EXEC_PLUGIN_CONFIG>} : null

this error is thrown:

    │ Error: Value Conversion Error
    │
    │   with provider["registry.terraform.io/fluxcd/flux"],
    │   on providers.tf line 54, in provider "flux":
    │   54: provider "flux" {
    │
    │ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following
    │ to the provider developer:
    │
    │ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a
    │ custom type that handles unknown values.
    │
    │ Path: kubernetes.exec
    │ Target Type: *provider.KubernetesExec
    │ Suggested Type: basetypes.ObjectValue

Provider version: v1.0.1

gberenice avatar Aug 03 '23 09:08 gberenice