1

I am trying to mount a Kubernetes secret via a kubernetes_manifest like this, however, port is a number 5342

resource "kubernetes_manifest" "test" {
  manifest = {
    "apiVersion" = "secrets-store.csi.x-k8s.io/v1alpha1"
    "kind"       = "SecretProviderClass"
    "metadata" = {
      namespace = "test-namespace"
      "name"    = "test"
    }
    "spec" = {
      "provider" = "aws"
      "secretObjects" = [{
        "secretName" = "test"
        "type"       = "Opaque"
        data = [{
          "objectName" = "test123"
          "key"        = "port"
        }
]
      }]
      "parameters" = {
        objects = yamlencode([{
          objectName  = aws_secretsmanager_secret.test.name
          objectType  = "secretsmanager"
          objectAlias = "test"
          jmesPath = [{
            path        = "port"
            objectAlias = "test123"
          }]
        }])
      }
    }
  }
}

When I terraform apply this, I get the error:

err: rpc error: code = Unknown desc = Invalid JMES search result type for path:port. Only string is allowed

Is there a way to mount port despite it being a number? Can I convert it to a string somehow?

jipot
  • 304
  • 3
  • 13
  • 34

1 Answers1

1

JMESPath does have a to_string function.

So, you can use a JMESPath query in the path field and do:

path        = "to_string(port)"
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83