Skip to content

Commit

Permalink
Merge branch 'master' into nija-at/apigwv2-moveintegrations
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 9, 2020
2 parents b0124db + 474f6c6 commit d0c8ce6
Show file tree
Hide file tree
Showing 124 changed files with 5,393 additions and 1,226 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
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"**/jszip/**",
"@aws-cdk/aws-codepipeline-actions/case",
"@aws-cdk/aws-codepipeline-actions/case/**",
"@aws-cdk/aws-cognito/punycode",
"@aws-cdk/aws-cognito/punycode/**",
"@aws-cdk/aws-ecr-assets/minimatch",
"@aws-cdk/aws-ecr-assets/minimatch/**",
"@aws-cdk/aws-eks/yaml",
Expand All @@ -79,6 +81,8 @@
"aws-cdk-lib/jsonschema/**",
"aws-cdk-lib/minimatch",
"aws-cdk-lib/minimatch/**",
"aws-cdk-lib/punycode",
"aws-cdk-lib/punycode/**",
"aws-cdk-lib/semver",
"aws-cdk-lib/semver/**",
"aws-cdk-lib/yaml",
Expand All @@ -91,6 +95,8 @@
"monocdk/jsonschema/**",
"monocdk/minimatch",
"monocdk/minimatch/**",
"monocdk/punycode",
"monocdk/punycode/**",
"monocdk/semver",
"monocdk/semver/**",
"monocdk/yaml",
Expand Down
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
9 changes: 4 additions & 5 deletions packages/@aws-cdk/aws-apigateway/lib/api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IResource as IResourceBase, Resource, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApiKey } from './apigateway.generated';
import { ResourceOptions } from './resource';
import { RestApi } from './restapi';
import { IRestApi } from './restapi';
import { QuotaSettings, ThrottleSettings, UsagePlan, UsagePlanPerApiStage } from './usage-plan';

/**
Expand Down Expand Up @@ -47,11 +47,10 @@ export interface ApiKeyOptions extends ResourceOptions {
*/
export interface ApiKeyProps extends ApiKeyOptions {
/**
* [disable-awslint:ref-via-interface]
* A list of resources this api key is associated with.
* @default none
*/
readonly resources?: RestApi[];
readonly resources?: IRestApi[];

/**
* An AWS Marketplace customer identifier to use when integrating with the AWS SaaS Marketplace.
Expand Down Expand Up @@ -183,12 +182,12 @@ export class ApiKey extends ApiKeyBase {
});
}

private renderStageKeys(resources: RestApi[] | undefined): CfnApiKey.StageKeyProperty[] | undefined {
private renderStageKeys(resources: IRestApi[] | undefined): CfnApiKey.StageKeyProperty[] | undefined {
if (!resources) {
return undefined;
}

return resources.map((resource: RestApi) => {
return resources.map((resource: IRestApi) => {
const restApi = resource;
const restApiId = restApi.restApiId;
const stageName = restApi.deploymentStage!.stageName.toString();
Expand Down
20 changes: 10 additions & 10 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ export abstract class RestApiBase extends Resource implements IRestApi {
});
}

/**
* Add an ApiKey
*/
public addApiKey(id: string, options?: ApiKeyOptions): IApiKey {
return new ApiKey(this, id, {
resources: [this],
...options,
});
}

/**
* Returns the given named metric for this API
*/
Expand Down Expand Up @@ -706,16 +716,6 @@ export class RestApi extends RestApiBase {
return this.urlForPath();
}

/**
* Add an ApiKey
*/
public addApiKey(id: string, options?: ApiKeyOptions): IApiKey {
return new ApiKey(this, id, {
resources: [this],
...options,
});
}

/**
* Adds a new model.
*/
Expand Down
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/restapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,34 @@ describe('restapi', () => {
},
});
});

test('addApiKey is supported', () => {
// GIVEN
const stack = new Stack();
const api = new apigw.SpecRestApi(stack, 'myapi', {
apiDefinition: apigw.ApiDefinition.fromInline({ foo: 'bar' }),
});
api.root.addMethod('OPTIONS');

// WHEN
api.addApiKey('myapikey', {
apiKeyName: 'myApiKey1',
value: '01234567890ABCDEFabcdef',
});

// THEN
expect(stack).toHaveResource('AWS::ApiGateway::ApiKey', {
Enabled: true,
Name: 'myApiKey1',
StageKeys: [
{
RestApiId: { Ref: 'myapi162F20B8' },
StageName: { Ref: 'myapiDeploymentStageprod329F21FF' },
},
],
Value: '01234567890ABCDEFabcdef',
});
});
});

describe('Metrics', () => {
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');
```
Loading

0 comments on commit d0c8ce6

Please sign in to comment.