Skip to content

Commit

Permalink
Merge branch 'master' into addL2PatternProps
Browse files Browse the repository at this point in the history
  • Loading branch information
piradeepk authored Sep 24, 2019
2 parents 8f3316e + 0731c3d commit 74f232e
Showing 1 changed file with 58 additions and 69 deletions.
127 changes: 58 additions & 69 deletions packages/@aws-cdk/aws-appmesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ The following example creates the `AppMesh` service mesh with the default filter

```typescript
const mesh = new Mesh(stack, 'AppMesh', {
name: 'myAwsmMesh',
meshName: 'myAwsmMesh',
});
```

The mesh can also be created with the "ALLOW_ALL" egress filter by overwritting the property.

```typescript
const mesh = new Mesh(stack, 'AppMesh', {
name: 'myAwsmMesh',
meshSpec: {
egressFilter: appmesh.MeshFilterType.Allow_All,
},
meshName: 'myAwsmMesh',
egressFilter: MeshFilterType.ALLOW_ALL,
});
```

Expand All @@ -64,33 +62,31 @@ Virtual routers handle traffic for one or more virtual services within your mesh

```typescript
const router = mesh.addVirtualRouter('router', {
portMappings: [
{
listener: {
portMapping: {
port: 8081,
protocol: appmesh.Protocol.HTTP,
},
],
protocol: Protocol.HTTP,
}
}
});
```

The router can also be created using the constructor and passing in the mesh instead of calling the addVirtualRouter() method for the mesh.

```typescript
const mesh = new Mesh(stack, 'AppMesh', {
name: 'myAwsmMesh',
meshSpec: {
egressFilter: appmesh.MeshFilterType.Allow_All,
},
meshName: 'myAwsmMesh',
egressFilter: MeshFilterType.Allow_All,
});

const router = new appmesh.VirtualRouter(stack, 'router', {
const router = new VirtualRouter(stack, 'router', {
mesh, // notice that mesh is a required property when creating a router with a new statement
portMappings: [
{
listener: {
portMapping: {
port: 8081,
protocol: appmesh.Protocol.HTTP,
},
],
protocol: Protocol.HTTP,
}
}
});
```

Expand Down Expand Up @@ -144,65 +140,58 @@ The response metadata for your new `virtual node` contains the Amazon Resource N
```typescript
const vpc = new ec2.Vpc(stack, 'vpc');
const namespace = new cloudmap.PrivateDnsNamespace(stack, 'test-namespace', {
vpc,
name: 'domain.local',
const namespace = new servicediscovery.PrivateDnsNamespace(this, 'test-namespace', {
vpc,
name: 'domain.local',
});
const service = namespace.createService('Svc');

const node = mesh.addVirtualNode('virtual-node', {
hostname: 'node-a',
namespace,
listeners: {
portMappings: [
{
port: 8081,
protocol: appmesh.Protocol.HTTP,
},
],
healthChecks: [
{
healthyThreshold: 3,
intervalMillis: 5000, // minimum
path: `/health-check-path`,
port: 8080,
protocol: appmesh.Protocol.HTTP,
timeoutMillis: 2000, // minimum
unhealthyThreshold: 2,
},
],
dnsHostName: 'node-a',
cloudMapService: service,
listener: {
portMapping: {
port: 8081,
protocol: Protocol.HTTP,
},
healthCheck: {
healthyThreshold: 3,
interval: Duration.seconds(5), // minimum
path: `/health-check-path`,
port: 8080,
protocol: Protocol.HTTP,
timeout: Duration.seconds(2), // minimum
unhealthyThreshold: 2,
},
},
});
})
```

Create a `VirtualNode` with the the constructor and add tags.

```typescript
const node = new appmesh.VirtualNode(stack, 'node', {
const node = new VirtualNode(this, 'node', {
mesh,
hostname: 'node-1',
namespace,
dnsHostName: 'node-1',
cloudMapService: service,
listener: {
portMappings: [
{
port: 8080,
protocol: appmesh.Protocol.HTTP,
},
],
healthChecks: [
{
healthyThreshold: 3,
intervalMillis: 5000, // min
path: '/ping',
port: 8080,
protocol: appmesh.Protocol.HTTP,
timeoutMillis: 2000, // min
unhealthyThreshold: 2,
},
],
portMapping: {
port: 8080,
protocol: Protocol.HTTP,
},
healthCheck: {
healthyThreshold: 3,
interval: Duration.seconds(5), // min
path: '/ping',
port: 8080,
protocol: Protocol.HTTP,
timeout: Duration.seconds(2), // min
unhealthyThreshold: 2,
},
},
});

node.node.apply(new cdk.Tag('Environment', 'Dev'));
cdk.Tag.add(node, 'Environment', 'Dev');
```

The listeners property can be left blank dded later with the `mesh.addListeners()` method. The `healthcheck` property is optional but if specifying a listener, the `portMappings` must contain at least one property.
Expand All @@ -224,7 +213,7 @@ router.addRoute('route', {
},
],
prefix: `/path-to-app`,
isHttpRoute: true,
routeType: RouteType.HTTP,
});
```

Expand All @@ -243,7 +232,7 @@ router.addRoute('route', {
},
],
prefix: `/path-to-app`,
isHttpRoute: true,
routeType: RouteType.HTTP,
});
```

Expand All @@ -261,7 +250,7 @@ ratingsRouter.addRoutes(
},
],
prefix: `/path-to-app`,
isHttpRoute: true,
routeType: RouteType.HTTP,
},
{
routeTargets: [
Expand All @@ -271,7 +260,7 @@ ratingsRouter.addRoutes(
},
],
prefix: `/path-to-app2`,
isHttpRoute: true,
routeType: RouteType.HTTP,
},
]
);
Expand Down

0 comments on commit 74f232e

Please sign in to comment.