1. Answers
  2. Setting up AWS AppMesh using Pulumi

How do I set up AWS AppMesh using Pulumi?

In this guide, you will learn how to set up AWS AppMesh using Pulumi with TypeScript. AWS AppMesh is a service mesh that makes it easy to monitor and control microservices running on AWS. We will create a service mesh, a virtual router, a virtual node, and a virtual service.

Key Points:

  • Define an AppMesh service mesh.
  • Create a virtual router within the mesh.
  • Define a virtual node.
  • Create a virtual service that uses the virtual node.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create an AppMesh service mesh
const serviceMesh = new aws.appmesh.Mesh("serviceMesh", {
    name: "my-mesh",
    spec: {
        egressFilter: {
            type: "ALLOW_ALL",
        },
    },
});

// Create a virtual router within the mesh
const virtualRouter = new aws.appmesh.VirtualRouter("virtualRouter", {
    meshName: serviceMesh.name,
    name: "my-router",
    spec: {
        listeners: [{
            portMapping: {
                port: 8080,
                protocol: "http",
            },
        }],
    },
});

// Define a virtual node
const virtualNode = new aws.appmesh.VirtualNode("virtualNode", {
    meshName: serviceMesh.name,
    name: "my-node",
    spec: {
        listeners: [{
            portMapping: {
                port: 8080,
                protocol: "http",
            },
        }],
        serviceDiscovery: {
            dns: {
                hostname: "my-service.local",
            },
        },
    },
});

// Create a virtual service that uses the virtual node
const virtualService = new aws.appmesh.VirtualService("virtualService", {
    meshName: serviceMesh.name,
    name: "my-service.local",
    spec: {
        provider: {
            virtualNode: {
                virtualNodeName: virtualNode.name,
            },
        },
    },
});

// Export the names of the created resources
export const meshName = serviceMesh.name;
export const routerName = virtualRouter.name;
export const nodeName = virtualNode.name;
export const serviceName = virtualService.name;

Summary:

In this guide, we created an AWS AppMesh service mesh using Pulumi with TypeScript. We defined a service mesh, a virtual router, a virtual node, and a virtual service. These components work together to manage and monitor microservices in a service mesh architecture.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up