Skip to content

Commit

Permalink
Merge branch 'master' into filter-subnets-by-ip-addr
Browse files Browse the repository at this point in the history
  • Loading branch information
flemjame-at-amazon authored Jun 18, 2020
2 parents 3f3859a + 4b68655 commit d6cdc2a
Show file tree
Hide file tree
Showing 349 changed files with 6,888 additions and 1,235 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "\U0001F41B Bug Report"
about: Report a bug
title: "[module]: "
labels: bug, needs-triage
---

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/doc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "📕 Documentation Issue"
about: Issue in the reference documentation or developer guide
title: "[module]: "
labels: feature-request, documentation, needs-triage
---

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "\U0001F680 Feature Request"
about: Request a new feature
title: "[module]: "
labels: feature-request, needs-triage
---

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/general-issues.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "\U00002753 General Issue"
about: Create a new issue
title: "[module]: "
labels: needs-triage
---

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
# Setting messages to an empty string will cause the automation to skip
# that category
ancient-issue-message: This issue has not received any attention in 2 years. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
ancient-issue-message: This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
stale-issue-message: This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
stale-pr-message: This PR has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

Expand All @@ -32,7 +32,7 @@ jobs:
# Issue timing
days-before-stale: 7
days-before-close: 4
days-before-ancient: 730
days-before-ancient: 365

# If you don't want to mark a issue as being ancient based on a
# threshold of "upvotes", you can set this here. An "upvote" is
Expand Down
171 changes: 171 additions & 0 deletions .github/workflows/issue-label-assign.yml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"devDependencies": {
"conventional-changelog-cli": "^2.0.34",
"fs-extra": "^9.0.1",
"graceful-fs": "^4.2.4",
"jsii-diff": "^1.6.0",
"jsii-pacmak": "^1.6.0",
"jsii-rosetta": "^1.6.0",
"lerna": "^3.22.1",
"standard-version": "^8.0.0",
"graceful-fs": "^4.2.4",
"typescript": "~3.8.3"
},
"resolutions-comment": "should be removed or reviewed when nodeunit dependency is dropped or adjusted",
Expand Down Expand Up @@ -62,12 +62,16 @@
"@aws-cdk/cloud-assembly-schema/semver/**",
"@aws-cdk/cloudformation-include/yaml",
"@aws-cdk/cloudformation-include/yaml/**",
"@aws-cdk/core/fs-extra",
"@aws-cdk/core/fs-extra/**",
"@aws-cdk/core/minimatch",
"@aws-cdk/core/minimatch/**",
"@aws-cdk/cx-api/semver",
"@aws-cdk/cx-api/semver/**",
"monocdk-experiment/case",
"monocdk-experiment/case/**",
"monocdk-experiment/fs-extra",
"monocdk-experiment/fs-extra/**",
"monocdk-experiment/jsonschema",
"monocdk-experiment/jsonschema/**",
"monocdk-experiment/minimatch",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/alexa-ask/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
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 @@ -57,7 +57,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"fast-check": "^1.24.2",
"fast-check": "^1.25.1",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^25.2.3",
"@types/jest": "^26.0.0",
"cdk-build-tools": "0.0.0",
"jest": "^25.5.4",
"pkglint": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-accessanalyzer/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-acmpca/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amazonmq/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ export enum RedirectStatus {
* Not found (404)
*/
NOT_FOUND = '404',

/**
* Not found rewrite (404)
*/
NOT_FOUND_REWRITE = '404-200',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const baseConfig = require('../../../tools/cdk-build-tools/config/eslintrc');
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
27 changes: 25 additions & 2 deletions packages/@aws-cdk/aws-apigateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ running on AWS Lambda, or any web application.
## Table of Contents

- [Defining APIs](#defining-apis)
- [Breaking up Methods and Resources across Stacks](#breaking-up-methods-and-resources-across-stacks)
- [AWS Lambda-backed APIs](#aws-lambda-backed-apis)
- [Integration Targets](#integration-targets)
- [Working with models](#working-with-models)
Expand Down Expand Up @@ -99,6 +100,18 @@ item.addMethod('GET'); // GET /items/{item}
item.addMethod('DELETE', new apigateway.HttpIntegration('http://amazon.com'));
```

### Breaking up Methods and Resources across Stacks

It is fairly common for REST APIs with a large number of Resources and Methods to hit the [CloudFormation
limit](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) of 200 resources per
stack.

To help with this, Resources and Methods for the same REST API can be re-organized across multiple stacks. A common
way to do this is to have a stack per Resource or groups of Resources, but this is not the only possible way.
The following example uses sets up two Resources '/pets' and '/books' in separate stacks using nested stacks:

[Resources grouped into nested stacks](test/integ.restapi-import.lit.ts)

## Integration Targets

Methods are associated with backend integrations, which are invoked when this
Expand Down Expand Up @@ -956,17 +969,27 @@ The following code creates a REST API using an external OpenAPI definition JSON
const api = new apigateway.SpecRestApi(this, 'books-api', {
apiDefinition: apigateway.ApiDefinition.fromAsset('path-to-file.json')
});

const booksResource = api.root.addResource('books')
booksResource.addMethod('GET', ...);
```
It is possible to use the `addResource()` API to define additional API Gateway Resources.
**Note:** Deployment will fail if a Resource of the same name is already defined in the Open API specification.
**Note:** Any default properties configured, such as `defaultIntegration`, `defaultMethodOptions`, etc. will only be
applied to Resources and Methods defined in the CDK, and not the ones defined in the spec. Use the [API Gateway
extensions to OpenAPI](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html)
to configure these.
There are a number of limitations in using OpenAPI definitions in API Gateway. Read the [Amazon API Gateway important
notes for REST APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html#api-gateway-known-issues-rest-apis)
for more details.
**Note:** When starting off with an OpenAPI definition using `SpecRestApi`, it is not possible to configure some
properties that can be configured directly in the OpenAPI specification file. This is to prevent people duplication
of these properties and potential confusion.
Further, it is currently also not possible to configure Methods and Resources in addition to the ones in the
specification file.
## APIGateway v2
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/authorizer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Construct, Resource, ResourceProps } from '@aws-cdk/core';
import { AuthorizationType } from './method';
import { RestApi } from './restapi';
import { IRestApi } from './restapi';

const AUTHORIZER_SYMBOL = Symbol.for('@aws-cdk/aws-apigateway.Authorizer');

Expand Down Expand Up @@ -28,7 +28,7 @@ export abstract class Authorizer extends Resource implements IAuthorizer {
* Called when the authorizer is used from a specific REST API.
* @internal
*/
public abstract _attachToApi(restApi: RestApi): void;
public abstract _attachToApi(restApi: IRestApi): void;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as lambda from '@aws-cdk/aws-lambda';
import { Construct, Duration, Lazy, Stack } from '@aws-cdk/core';
import { CfnAuthorizer } from '../apigateway.generated';
import { Authorizer, IAuthorizer } from '../authorizer';
import { RestApi } from '../restapi';
import { IRestApi } from '../restapi';

/**
* Base properties for all lambda authorizers
Expand Down Expand Up @@ -83,7 +83,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
* Attaches this authorizer to a specific REST API.
* @internal
*/
public _attachToApi(restApi: RestApi) {
public _attachToApi(restApi: IRestApi) {
if (this.restApiId && this.restApiId !== restApi.restApiId) {
throw new Error('Cannot attach authorizer to two different rest APIs');
}
Expand Down
7 changes: 6 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/domain-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as acm from '@aws-cdk/aws-certificatemanager';
import { Construct, IResource, Resource } from '@aws-cdk/core';
import { Construct, IResource, Resource, Token } from '@aws-cdk/core';
import { CfnDomainName } from './apigateway.generated';
import { BasePathMapping, BasePathMappingOptions } from './base-path-mapping';
import { EndpointType, IRestApi } from './restapi';
Expand Down Expand Up @@ -102,6 +102,11 @@ export class DomainName extends Resource implements IDomainName {
const endpointType = props.endpointType || EndpointType.REGIONAL;
const edge = endpointType === EndpointType.EDGE;

if (!Token.isUnresolved(props.domainName) && /[A-Z]/.test(props.domainName)) {
throw new Error('domainName does not support uppercase letters. ' +
`got: '${props.domainName}'`);
}

const resource = new CfnDomainName(this, 'Resource', {
domainName: props.domainName,
certificateArn: edge ? props.certificate.certificateArn : undefined,
Expand Down
27 changes: 20 additions & 7 deletions packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MethodResponse } from './methodresponse';
import { IModel } from './model';
import { IRequestValidator, RequestValidatorOptions } from './requestvalidator';
import { IResource } from './resource';
import { RestApi } from './restapi';
import { IRestApi, RestApi, RestApiBase } from './restapi';
import { validateHttpMethod } from './util';

export interface MethodOptions {
Expand Down Expand Up @@ -159,13 +159,16 @@ export class Method extends Resource {

public readonly httpMethod: string;
public readonly resource: IResource;
public readonly restApi: RestApi;
/**
* The API Gateway RestApi associated with this method.
*/
public readonly api: IRestApi;

constructor(scope: Construct, id: string, props: MethodProps) {
super(scope, id);

this.resource = props.resource;
this.restApi = props.resource.restApi;
this.api = props.resource.api;
this.httpMethod = props.httpMethod.toUpperCase();

validateHttpMethod(this.httpMethod);
Expand All @@ -186,12 +189,12 @@ export class Method extends Resource {
}

if (Authorizer.isAuthorizer(authorizer)) {
authorizer._attachToApi(this.restApi);
authorizer._attachToApi(this.api);
}

const methodProps: CfnMethodProps = {
resourceId: props.resource.resourceId,
restApiId: this.restApi.restApiId,
restApiId: this.api.restApiId,
httpMethod: this.httpMethod,
operationName: options.operationName || defaultMethodOptions.operationName,
apiKeyRequired: options.apiKeyRequired || defaultMethodOptions.apiKeyRequired,
Expand All @@ -209,15 +212,25 @@ export class Method extends Resource {

this.methodId = resource.ref;

props.resource.restApi._attachMethod(this);
if (RestApiBase._isRestApiBase(props.resource.api)) {
props.resource.api._attachMethod(this);
}

const deployment = props.resource.restApi.latestDeployment;
const deployment = props.resource.api.latestDeployment;
if (deployment) {
deployment.node.addDependency(resource);
deployment.addToLogicalId({ method: methodProps });
}
}

/**
* The RestApi associated with this Method
* @deprecated - Throws an error if this Resource is not associated with an instance of `RestApi`. Use `api` instead.
*/
public get restApi(): RestApi {
return this.resource.restApi;
}

/**
* Returns an execute-api ARN for this method:
*
Expand Down
Loading

0 comments on commit d6cdc2a

Please sign in to comment.