Resource: aws_appmesh_virtual_node

Provides an AWS App Mesh virtual node resource.

Breaking Changes

Because of backward incompatible API changes (read here), aws_appmesh_virtual_node resource definitions created with provider versions earlier than v2.3.0 will need to be modified:

The Terraform state associated with existing resources will automatically be migrated.

Example Usage

Basic

resource "aws_appmesh_virtual_node" "serviceb1" {
  name      = "serviceBv1"
  mesh_name = aws_appmesh_mesh.simple.id

  spec {
    backend {
      virtual_service {
        virtual_service_name = "servicea.simpleapp.local"
      }
    }

    listener {
      port_mapping {
        port     = 8080
        protocol = "http"
      }
    }

    service_discovery {
      dns {
        hostname = "serviceb.simpleapp.local"
      }
    }
  }
}

AWS Cloud Map Service Discovery

resource "aws_service_discovery_http_namespace" "example" {
  name = "example-ns"
}

resource "aws_appmesh_virtual_node" "serviceb1" {
  name      = "serviceBv1"
  mesh_name = aws_appmesh_mesh.simple.id

  spec {
    backend {
      virtual_service {
        virtual_service_name = "servicea.simpleapp.local"
      }
    }

    listener {
      port_mapping {
        port     = 8080
        protocol = "http"
      }
    }

    service_discovery {
      aws_cloud_map {
        attributes = {
          stack = "blue"
        }

        service_name   = "serviceb1"
        namespace_name = aws_service_discovery_http_namespace.example.name
      }
    }
  }
}

Listener Health Check

resource "aws_appmesh_virtual_node" "serviceb1" {
  name      = "serviceBv1"
  mesh_name = aws_appmesh_mesh.simple.id

  spec {
    backend {
      virtual_service {
        virtual_service_name = "servicea.simpleapp.local"
      }
    }

    listener {
      port_mapping {
        port     = 8080
        protocol = "http"
      }

      health_check {
        protocol            = "http"
        path                = "/ping"
        healthy_threshold   = 2
        unhealthy_threshold = 2
        timeout_millis      = 2000
        interval_millis     = 5000
      }
    }

    service_discovery {
      dns {
        hostname = "serviceb.simpleapp.local"
      }
    }
  }
}

Logging

resource "aws_appmesh_virtual_node" "serviceb1" {
  name      = "serviceBv1"
  mesh_name = aws_appmesh_mesh.simple.id

  spec {
    backend {
      virtual_service {
        virtual_service_name = "servicea.simpleapp.local"
      }
    }

    listener {
      port_mapping {
        port     = 8080
        protocol = "http"
      }
    }

    service_discovery {
      dns {
        hostname = "serviceb.simpleapp.local"
      }
    }

    logging {
      access_log {
        file {
          path = "/dev/stdout"
        }
      }
    }
  }
}

Argument Reference

This resource supports the following arguments:

The spec object supports the following:

The backend object supports the following:

The virtual_service object supports the following:

The client_policy object supports the following:

The tls object supports the following:

The certificate object supports the following:

The file object supports the following:

The sds object supports the following:

The validation object supports the following:

The subject_alternative_names object supports the following:

The match object supports the following:

The trust object supports the following:

The acm object supports the following:

The file object supports the following:

The sds object supports the following:

The backend_defaults object supports the following:

The listener object supports the following:

The logging object supports the following:

The access_log object supports the following:

The file object supports the following:

The format object supports the following:

The json object supports the following:

The service_discovery object supports the following:

The aws_cloud_map object supports the following:

The dns object supports the following:

The port_mapping object supports the following:

The connection_pool object supports the following:

The grpc connection pool object supports the following:

The http connection pool object supports the following:

The http2 connection pool object supports the following:

The tcp connection pool object supports the following:

The health_check object supports the following:

The outlier_detection object supports the following:

The base_ejection_duration and interval objects support the following:

The timeout object supports the following:

The grpc timeout object supports the following:

The idle and per_request objects support the following:

The http and http2 timeout objects support the following:

The idle and per_request objects support the following:

The tcp timeout object supports the following:

The idle object supports the following:

The tls object supports the following:

The certificate object supports the following:

The acm object supports the following:

The file object supports the following:

The sds object supports the following:

The validation object supports the following:

The subject_alternative_names object supports the following:

The match object supports the following:

The trust object supports the following:

The file object supports the following:

The sds object supports the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import App Mesh virtual nodes using mesh_name together with the virtual node's name. For example:

import {
  to = aws_appmesh_virtual_node.serviceb1
  id = "simpleapp/serviceBv1"
}

Using terraform import, import App Mesh virtual nodes using mesh_name together with the virtual node's name. For example:

% terraform import aws_appmesh_virtual_node.serviceb1 simpleapp/serviceBv1