Kubernetes Manifest Terraform Virtual Node AWS AppMesh

245 views Asked by At

I am trying to update my Virtual Node for AWS App Mesh via its Terraform configuration (that has worked and been deployed prior). I am adding a serviceDiscovery ReponseType variable to it so that I can change that value. Currently my code looks like this:

# Virtual Node Creation --------------------------------
resource "kubernetes_manifest" "service_virtual_node" {
  manifest = {
    "apiVersion" = "appmesh.k8s.aws/v1beta2"
    "kind"       = "VirtualNode"
    "metadata" = {
      "name"      = "${var.team_name}-${var.service_name}-virtual-node"
      "namespace" = "${var.kubernetes_namespace}"
    }
    "spec" = {
      "podSelector" = {
        "matchLabels" = {
          "app" = "${var.service_name}"
        }
      }
      "listeners" = [{
        "portMapping" = {
          "port"     = "${var.appmesh_port}"
          "protocol" = "${var.service_protocol}"
        }
      }]
      "serviceDiscovery" = {
        "dns" = {
          "hostname"     = var.load_balancer_type == "internal" ? "${var.service_name}.${var.dns_zone_name}" : "${var.service_name}-external.${var.dns_zone_name}"
          "responseType" = var.service_discovery_response_type
        }
      }
      logging = {
        accessLog = {
          file = {
            path = "/dev/stdout"
          }
        }
      }
    }
  }
}

It seems to be complaining about my new line:

"responseType" = var.service_discovery_response_type

The weird part about this, is that I deployed the same code (terraform module) to three other services without complaint. The error that I am now recieving from this is:

╷
│ Error: Failed to morph manifest to OAPI type
│ 
│   with module.services.module.accounts-api.module.appmesh.kubernetes_manifest.service_virtual_node,
│   on .terraform/modules/services.accounts-api.appmesh/kubernetes_manifest.tf line 2, in resource "kubernetes_manifest" "service_virtual_node":
│    2: resource "kubernetes_manifest" "service_virtual_node" {
│ 
│ AttributeName("spec"): [AttributeName("spec")] failed to morph object element into object element: AttributeName("spec").AttributeName("serviceDiscovery"):
│ [AttributeName("spec").AttributeName("serviceDiscovery")] failed to morph object element into object element: AttributeName("spec").AttributeName("serviceDiscovery").AttributeName("dns"):
│ [AttributeName("spec").AttributeName("serviceDiscovery").AttributeName("dns")] failed to morph object element into object element:
│ AttributeName("spec").AttributeName("serviceDiscovery").AttributeName("dns").AttributeName("responseType"):
│ [AttributeName("spec").AttributeName("serviceDiscovery").AttributeName("dns").AttributeName("responseType")] failed to morph object element into object element:
│ AttributeName("spec").AttributeName("serviceDiscovery").AttributeName("dns").AttributeName("responseType"): type is nil

I am not sure why the same code is now failing. I have tried adding "${}" around the variable, and also adding brackets as well. Both failed.

0

There are 0 answers