Skip to content

Commit

Permalink
Merge branch 'master' into wtho/cognito-userpool-punycode-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 9, 2020
2 parents be3ec3f + 4887ba6 commit 319795a
Show file tree
Hide file tree
Showing 103 changed files with 4,777 additions and 1,204 deletions.
1 change: 1 addition & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ account: '123456789012'
account: '772975370895'
account: '856666278305'
account: '840364872350'
account: '422531588944'
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ and let us know if it's not up-to-date (even better, submit a PR with your corr
- [API Compatibility Checks](#api-compatibility-checks)
- [Examples](#examples)
- [Feature Flags](#feature-flags)
- [Versioning](#versioning)
- [Versioning and Release](#versioning-and-release)
- [Troubleshooting](#troubleshooting)
- [Debugging](#debugging)
- [Connecting the VS Code Debugger](#connecting-the-vs-code-debugger)
Expand Down
6 changes: 5 additions & 1 deletion allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# and that won't typecheck if Manifest.load() adds a union arm and now returns A | B | C.
change-return-type:@aws-cdk/cloud-assembly-schema.Manifest.load

# Adding any new context queries will add to the ContextQueryProperties type,
# which changes the signature of MissingContext.
weakened:@aws-cdk/cloud-assembly-schema.MissingContext

removed:@aws-cdk/core.BootstraplessSynthesizer.DEFAULT_ASSET_PUBLISHING_ROLE_ARN
removed:@aws-cdk/core.DefaultStackSynthesizer.DEFAULT_ASSET_PUBLISHING_ROLE_ARN
removed:@aws-cdk/core.DefaultStackSynthesizerProps.assetPublishingExternalId
Expand Down Expand Up @@ -47,4 +51,4 @@ incompatible-argument:@aws-cdk/aws-ecs.Ec2TaskDefinition.addVolume
incompatible-argument:@aws-cdk/aws-ecs.FargateTaskDefinition.<initializer>
incompatible-argument:@aws-cdk/aws-ecs.FargateTaskDefinition.addVolume
incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.<initializer>
incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.addVolume
incompatible-argument:@aws-cdk/aws-ecs.TaskDefinition.addVolume
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,9 @@ export class AppMeshExtension extends ServiceExtension {
// and other similar behaviors.
this.virtualRouter = new appmesh.VirtualRouter(this.scope, `${this.parentService.id}-virtual-router`, {
mesh: this.mesh,
listener: {
portMapping: {
port: containerextension.trafficPort,
protocol: this.protocol,
},
},
listeners: [
this.virtualRouterListener(containerextension.trafficPort),
],
virtualRouterName: `${this.parentService.id}`,
});

Expand Down Expand Up @@ -331,4 +328,13 @@ export class AppMeshExtension extends ServiceExtension {
// nodes from the other service.
this.virtualNode.addBackends(otherAppMesh.virtualService);
}

private virtualRouterListener(port: number): appmesh.VirtualRouterListener {
switch (this.protocol) {
case appmesh.Protocol.HTTP: return appmesh.VirtualRouterListener.http(port);
case appmesh.Protocol.HTTP2: return appmesh.VirtualRouterListener.http2(port);
case appmesh.Protocol.GRPC: return appmesh.VirtualRouterListener.grpc(port);
case appmesh.Protocol.TCP: return appmesh.VirtualRouterListener.tcp(port);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3323,7 +3323,7 @@
"ecrRepo": "840364872350"
},
"eu-south-1": {
"ecrRepo": "840364872350"
"ecrRepo": "422531588944"
},
"eu-west-1": {
"ecrRepo": "840364872350"
Expand Down Expand Up @@ -3382,7 +3382,7 @@
"ecrRepo": "840364872350"
},
"eu-south-1": {
"ecrRepo": "840364872350"
"ecrRepo": "422531588944"
},
"eu-west-1": {
"ecrRepo": "840364872350"
Expand Down Expand Up @@ -3441,7 +3441,7 @@
"ecrRepo": "840364872350"
},
"eu-south-1": {
"ecrRepo": "840364872350"
"ecrRepo": "422531588944"
},
"eu-west-1": {
"ecrRepo": "840364872350"
Expand Down Expand Up @@ -3491,4 +3491,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,7 @@
"ecrRepo": "840364872350"
},
"eu-south-1": {
"ecrRepo": "840364872350"
"ecrRepo": "422531588944"
},
"eu-west-1": {
"ecrRepo": "840364872350"
Expand Down Expand Up @@ -2201,7 +2201,7 @@
"ecrRepo": "840364872350"
},
"eu-south-1": {
"ecrRepo": "840364872350"
"ecrRepo": "422531588944"
},
"eu-west-1": {
"ecrRepo": "840364872350"
Expand Down Expand Up @@ -2235,4 +2235,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"fast-check": "^2.6.0",
"fast-check": "^2.6.1",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"cdk-build-tools": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0",
"ts-jest": "^26.4.3"
"ts-jest": "^26.4.4"
},
"dependencies": {
"@aws-cdk/cloud-assembly-schema": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cfn2ts": "0.0.0",
"fast-check": "^2.6.0",
"fast-check": "^2.6.1",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0"
},
Expand Down
59 changes: 42 additions & 17 deletions packages/@aws-cdk/aws-appmesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,21 @@ const mesh = new Mesh(stack, 'AppMesh', {

## Adding VirtualRouters

The `Mesh` needs `VirtualRouters` as logical units to route to `VirtualNodes`.
The _Mesh_ needs _VirtualRouters_ as logical units to route requests to _VirtualNodes_.

Virtual routers handle traffic for one or more virtual services within your mesh. After you create a virtual router, you can create and associate routes for your virtual router that direct incoming requests to different virtual nodes.
Virtual routers handle traffic for one or more virtual services within your mesh.
After you create a virtual router, you can create and associate routes to your virtual router that direct incoming requests to different virtual nodes.

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

The router can also be created using the constructor and passing in the mesh instead of calling the addVirtualRouter() method for the mesh.
The router can also be created using the constructor and passing in the mesh instead of calling the `addVirtualRouter()` method for the mesh.
The same pattern applies to all constructs within the appmesh library, for any mesh.addXZY method, a new constuctor can also be used.
This is particularly useful for cross stack resources are required.
Where creating the `mesh` as part of an infrastructure stack and creating the `resources` such as `nodes` is more useful to keep in the application stack.

```typescript
const mesh = new Mesh(stack, 'AppMesh', {
Expand All @@ -78,18 +77,15 @@ const mesh = new Mesh(stack, 'AppMesh', {

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

The listener protocol can be either `HTTP` or `TCP`.

The same pattern applies to all constructs within the appmesh library, for any mesh.addXZY method, a new constuctor can also be used. This is particularly useful for cross stack resources are required. Where creating the `mesh` as part of an infrastructure stack and creating the `resources` such as `nodes` is more useful to keep in the application stack.
The _VirtualRouterListener_ class provides an easy interface for defining new protocol specific listeners.
The `http()`, `http2()`, `grpc()` and `tcp()` methods are available for use.
They accept a single port parameter, that is used to define what port to match requests on.
The port parameter can be omitted, and it will default to port 8080.

## Adding VirtualService

Expand Down Expand Up @@ -307,3 +303,32 @@ gateway.addGatewayRoute('gateway-route-grpc', {
}),
});
```

## Importing Resources

Each mesh resource comes with two static methods for importing a reference to an existing App Mesh resource.
These imported resources can be used as references for other resources in your mesh.
There are two static methods, `from<Resource>Arn` and `from<Resource>Attributes` where the `<Resource>` is replaced with the resource name.

```typescript
const arn = "arn:aws:appmesh:us-east-1:123456789012:mesh/testMesh/virtualNode/testNode";
appmesh.VirtualNode.fromVirtualNodeArn(stack, 'importedVirtualNode', arn);
```

```typescript
appmesh.VirtualNode.fromVirtualNodeAttributes(stack, 'imported-virtual-node', {
mesh: appmesh.Mesh.fromMeshName(stack, 'Mesh', 'testMesh'),
virtualNodeName: virtualNodeName,
});
```

To import a mesh, there are two static methods, `fromMeshArn` and `fromMeshName`.

```typescript
const arn = 'arn:aws:appmesh:us-east-1:123456789012:mesh/testMesh';
appmesh.Mesh.fromMeshArn(stack, 'imported-mesh', arn);
```

```typescript
appmesh.Mesh.fromMeshName(stack, 'imported-mesh', 'abc');
```
70 changes: 24 additions & 46 deletions packages/@aws-cdk/aws-appmesh/lib/gateway-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,26 @@ export class GatewayRoute extends cdk.Resource implements IGatewayRoute {
* Import an existing GatewayRoute given an ARN
*/
public static fromGatewayRouteArn(scope: Construct, id: string, gatewayRouteArn: string): IGatewayRoute {
return new ImportedGatewayRoute(scope, id, { gatewayRouteArn });
return new class extends cdk.Resource implements IGatewayRoute {
readonly gatewayRouteArn = gatewayRouteArn;
readonly gatewayRouteName = cdk.Fn.select(4, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(gatewayRouteArn).resourceName!));
readonly virtualGateway = VirtualGateway.fromVirtualGatewayArn(this, 'virtualGateway', gatewayRouteArn);
}(scope, id);
}

/**
* Import an existing GatewayRoute given attributes
*/
public static fromGatewayRouteAttributes(scope: Construct, id: string, attrs: GatewayRouteAttributes): IGatewayRoute {
return new class extends cdk.Resource implements IGatewayRoute {
readonly gatewayRouteName = attrs.gatewayRouteName;
readonly gatewayRouteArn = cdk.Stack.of(scope).formatArn({
service: 'appmesh',
resource: `mesh/${attrs.virtualGateway.mesh.meshName}/virtualGateway/${attrs.virtualGateway.virtualGatewayName}/gatewayRoute`,
resourceName: this.gatewayRouteName,
});
readonly virtualGateway = attrs.virtualGateway;
}(scope, id);
}

/**
Expand Down Expand Up @@ -114,55 +133,14 @@ export class GatewayRoute extends cdk.Resource implements IGatewayRoute {
/**
* Interface with properties necessary to import a reusable GatewayRoute
*/
interface GatewayRouteAttributes {
export interface GatewayRouteAttributes {
/**
* The name of the GatewayRoute
*/
readonly gatewayRouteName?: string;
readonly gatewayRouteName: string;

/**
* The Amazon Resource Name (ARN) for the GatewayRoute
* The VirtualGateway this GatewayRoute is associated with.
*/
readonly gatewayRouteArn?: string;

/**
* The name of the mesh this GatewayRoute is associated with
*/
readonly meshName?: string;

/**
* The name of the Virtual Gateway this GatewayRoute is associated with
*/
readonly virtualGateway?: IVirtualGateway;
}

/**
* Represents an imported IGatewayRoute
*/
class ImportedGatewayRoute extends cdk.Resource implements IGatewayRoute {
/**
* The name of the GatewayRoute
*/
public gatewayRouteName: string;

/**
* The Amazon Resource Name (ARN) for the GatewayRoute
*/
public gatewayRouteArn: string;

/**
* The VirtualGateway the GatewayRoute belongs to
*/
public virtualGateway: IVirtualGateway;

constructor(scope: Construct, id: string, props: GatewayRouteAttributes) {
super(scope, id);
if (props.gatewayRouteArn) {
this.gatewayRouteArn = props.gatewayRouteArn;
this.gatewayRouteName = cdk.Fn.select(4, cdk.Fn.split('/', cdk.Stack.of(scope).parseArn(props.gatewayRouteArn).resourceName!));
this.virtualGateway = VirtualGateway.fromVirtualGatewayArn(this, 'virtualGateway', props.gatewayRouteArn);
} else {
throw new Error('Need gatewayRouteArn');
}
}
readonly virtualGateway: IVirtualGateway;
}
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-appmesh/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './route';
export * from './shared-interfaces';
export * from './virtual-node';
export * from './virtual-router';
export * from './virtual-router-listener';
export * from './virtual-service';
export * from './virtual-gateway';
export * from './virtual-gateway-listener';
Expand Down
Loading

0 comments on commit 319795a

Please sign in to comment.