Skip to content

Commit

Permalink
Merge branch 'master' into autoscale-lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
NetaNir authored Aug 11, 2020
2 parents 9ab7fee + 9fa4cd0 commit 3519d02
Show file tree
Hide file tree
Showing 262 changed files with 1,824 additions and 519 deletions.
29 changes: 27 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pull_request_rules:
conditions:
- base!=release
- -title~=(WIP|wip)
- -label~=(blocked|do-not-merge|no-squash)
- -label~=(blocked|do-not-merge|no-squash|two-approvers)
- -merged
- -closed
- author!=dependabot[bot]
Expand All @@ -32,7 +32,32 @@ pull_request_rules:
- status-success~=AWS CodeBuild us-east-1
#- status-success=Semantic Pull Request
- status-success=mandatory-changes
- name: automatic merge
- name: automatic merge (2+ approvers)
actions:
comment:
message: Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to [allow changes to be pushed to your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)).
merge:
strict: smart
method: squash
strict_method: merge
commit_message: title+body
delete_head_branch: {}
conditions:
- base!=release
- -title~=(WIP|wip)
- label~=two-approvers
- -label~=(blocked|do-not-merge|no-squash)
- -merged
- -closed
- author!=dependabot[bot]
- author!=dependabot-preview[bot]
- "#approved-reviews-by>=2"
- -approved-reviews-by~=author
- "#changes-requested-reviews-by=0"
- status-success~=AWS CodeBuild us-east-1
#- status-success=Semantic Pull Request
- status-success=mandatory-changes
- name: automatic merge (no-squash)
actions:
comment:
message: Thank you for contributing! Your pull request will be updated from master and then merged automatically without squashing (do not update manually, and be sure to [allow changes to be pushed to your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class PipelineDeployStackAction implements codepipeline.IAction {

constructor(props: PipelineDeployStackActionProps) {
this.stack = props.stack;
const assets = this.stack.node.metadata.filter(md => md.type === cxschema.ArtifactMetadataEntryType.ASSET);
const assets = this.stack.construct.metadata.filter(md => md.type === cxschema.ArtifactMetadataEntryType.ASSET);
if (assets.length > 0) {
// FIXME: Implement the necessary actions to publish assets
throw new Error(`Cannot deploy the stack ${this.stack.stackName} because it references ${assets.length} asset(s)`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export = nodeunit.testCase({

const deployedStack = new cdk.Stack(app, 'DeployedStack');
for (let i = 0 ; i < assetCount ; i++) {
deployedStack.node.addMetadata(cxschema.ArtifactMetadataEntryType.ASSET, {});
deployedStack.construct.addMetadata(cxschema.ArtifactMetadataEntryType.ASSET, {});
}

test.throws(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/lib/synth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class SynthUtils {
* Synthesizes the app in which a stack resides and returns the cloud assembly object.
*/
function synthesizeApp(stack: core.Stack, options: core.SynthesisOptions) {
const root = stack.node.root;
const root = stack.construct.root;
if (!core.Stage.isStage(root)) {
throw new Error('unexpected: all stacks must be part of a Stage or an App');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/test/test.staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export = {
'staging can be disabled through context'(test: Test) {
// GIVEN
const stack = new Stack();
stack.node.setContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT, true);
stack.construct.setContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT, true);
const sourcePath = path.join(__dirname, 'fs', 'fixtures', 'test1');

// WHEN
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
description: props.description,
environmentVariables: Lazy.anyValue({ produce: () => renderEnvironmentVariables(this.environmentVariables) }, { omitEmptyArray: true }),
iamServiceRole: role.roleArn,
name: props.appName || this.node.id,
name: props.appName || this.construct.id,
oauthToken: sourceCodeProviderOptions?.oauthToken?.toString(),
repository: sourceCodeProviderOptions?.repository,
});
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface LambdaAuthorizerProps {
/**
* An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
*
* @default this.node.uniqueId
* @default this.construct.uniqueId
*/
readonly authorizerName?: string;

Expand Down Expand Up @@ -96,7 +96,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
*/
protected setupPermissions() {
if (!this.role) {
this.handler.addPermission(`${this.node.uniqueId}:Permissions`, {
this.handler.addPermission(`${this.construct.uniqueId}:Permissions`, {
principal: new iam.ServicePrincipal('apigateway.amazonaws.com'),
sourceArn: this.authorizerArn,
});
Expand All @@ -120,7 +120,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
return Lazy.stringValue({
produce: () => {
if (!this.restApiId) {
throw new Error(`Authorizer (${this.node.path}) must be attached to a RestApi`);
throw new Error(`Authorizer (${this.construct.path}) must be attached to a RestApi`);
}
return this.restApiId;
},
Expand Down Expand Up @@ -167,7 +167,7 @@ export class TokenAuthorizer extends LambdaAuthorizer {

const restApiId = this.lazyRestApiId();
const resource = new CfnAuthorizer(this, 'Resource', {
name: props.authorizerName ?? this.node.uniqueId,
name: props.authorizerName ?? this.construct.uniqueId,
restApiId,
type: 'TOKEN',
authorizerUri: lambdaAuthorizerArn(props.handler),
Expand Down Expand Up @@ -229,7 +229,7 @@ export class RequestAuthorizer extends LambdaAuthorizer {

const restApiId = this.lazyRestApiId();
const resource = new CfnAuthorizer(this, 'Resource', {
name: props.authorizerName ?? this.node.uniqueId,
name: props.authorizerName ?? this.construct.uniqueId,
restApiId,
type: 'REQUEST',
authorizerUri: lambdaAuthorizerArn(props.handler),
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class Deployment extends Resource {
// and the `AWS::Lambda::Permission` resources (children under Method),
// causing cyclic dependency errors. Hence, falling back to declaring
// dependencies between the underlying CfnResources.
this.node.addDependency(method.node.defaultChild as CfnResource);
this.construct.addDependency(method.construct.defaultChild as CfnResource);
}
}

Expand Down Expand Up @@ -150,7 +150,7 @@ class LatestDeploymentResource extends CfnDeployment {
public addToLogicalId(data: unknown) {
// if the construct is locked, it means we are already synthesizing and then
// we can't modify the hash because we might have already calculated it.
if (this.node.locked) {
if (this.construct.locked) {
throw new Error('Cannot modify the logical ID when the construct is locked');
}

Expand All @@ -163,7 +163,7 @@ class LatestDeploymentResource extends CfnDeployment {
if (this.api instanceof RestApi || this.api instanceof SpecRestApi) { // Ignore IRestApi that are imported

// Add CfnRestApi to the logical id so a new deployment is triggered when any of its properties change.
const cfnRestApiCF = (this.api.node.defaultChild as any)._toCloudFormation();
const cfnRestApiCF = (this.api.construct.defaultChild as any)._toCloudFormation();
hash.push(this.stack.resolve(cfnRestApiCF));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/domain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class DomainName extends Resource implements IDomainName {
*/
public addBasePathMapping(targetApi: IRestApi, options: BasePathMappingOptions = { }) {
const basePath = options.basePath || '/';
const id = `Map:${basePath}=>${targetApi.node.uniqueId}`;
const id = `Map:${basePath}=>${targetApi.construct.uniqueId}`;
return new BasePathMapping(this, id, {
domainName: this,
restApi: targetApi,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/gateway-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class GatewayResponse extends Resource implements IGatewayResponse {
statusCode: props.statusCode,
});

this.node.defaultChild = resource;
this.construct.defaultChild = resource;
}

private buildResponseParameters(responseHeaders?: { [key: string]: string }): { [key: string]: string } | undefined {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/integrations/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class LambdaIntegration extends AwsIntegration {
const bindResult = super.bind(method);
const principal = new iam.ServicePrincipal('apigateway.amazonaws.com');

const desc = `${method.api.node.uniqueId}.${method.httpMethod}.${method.resource.path.replace(/\//g, '.')}`;
const desc = `${method.api.construct.uniqueId}.${method.httpMethod}.${method.resource.path.replace(/\//g, '.')}`;

this.handler.addPermission(`ApiPermission.${desc}`, {
principal,
Expand All @@ -78,7 +78,7 @@ export class LambdaIntegration extends AwsIntegration {
if (this.handler instanceof lambda.Function) {
// if not imported, extract the name from the CFN layer to reach
// the literal value if it is given (rather than a token)
functionName = (this.handler.node.defaultChild as lambda.CfnFunction).functionName;
functionName = (this.handler.construct.defaultChild as lambda.CfnFunction).functionName;
} else {
// imported, just take the function name.
functionName = this.handler.functionName;
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class Method extends Resource {

const deployment = props.resource.api.latestDeployment;
if (deployment) {
deployment.node.addDependency(resource);
deployment.construct.addDependency(resource);
deployment.addToLogicalId({
method: {
...methodProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class Model extends Resource implements IModel {

const deployment = (props.restApi instanceof RestApi) ? props.restApi.latestDeployment : undefined;
if (deployment) {
deployment.node.addDependency(resource);
deployment.construct.addDependency(resource);
deployment.addToLogicalId({ model: modelProps });
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/requestvalidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class RequestValidator extends Resource implements IRequestValidator {

const deployment = (props.restApi instanceof RestApi) ? props.restApi.latestDeployment : undefined;
if (deployment) {
deployment.node.addDependency(resource);
deployment.construct.addDependency(resource);
deployment.addToLogicalId({ validator: validatorProps });
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class Resource extends ResourceBase {

const deployment = props.parent.api.latestDeployment;
if (deployment) {
deployment.node.addDependency(resource);
deployment.construct.addDependency(resource);
deployment.addToLogicalId({ resource: resourceProps });
}

Expand Down Expand Up @@ -488,7 +488,7 @@ export class ProxyResource extends Resource {
// the root so that empty paths are proxied as well.
if (this.parentResource && this.parentResource.path === '/') {
// skip if the root resource already has this method defined
if (!(this.parentResource.node.tryFindChild(httpMethod) instanceof Method)) {
if (!(this.parentResource.construct.tryFindChild(httpMethod) instanceof Method)) {
this.parentResource.addMethod(httpMethod, integration, options);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export abstract class RestApiBase extends Resource implements IRestApi {
cloudWatchRoleArn: role.roleArn,
});

resource.node.addDependency(apiResource);
resource.construct.addDependency(apiResource);
}

protected configureDeployment(props: RestApiOptions) {
Expand Down Expand Up @@ -492,7 +492,7 @@ export class SpecRestApi extends RestApiBase {
endpointConfiguration: this._configureEndpoints(props),
parameters: props.parameters,
});
this.node.defaultChild = resource;
this.construct.defaultChild = resource;
this.restApiId = resource.ref;
this.restApiRootResourceId = resource.attrRootResourceId;
this.root = new RootResource(this, {}, this.restApiRootResourceId);
Expand Down Expand Up @@ -597,7 +597,7 @@ export class RestApi extends RestApiBase {
cloneFrom: props.cloneFrom ? props.cloneFrom.restApiId : undefined,
parameters: props.parameters,
});
this.node.defaultChild = resource;
this.construct.defaultChild = resource;
this.restApiId = resource.ref;

const cloudWatchRole = props.cloudWatchRole !== undefined ? props.cloudWatchRole : true;
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class UsagePlan extends Resource {
const prefix = 'UsagePlanKeyResource';

// Postfixing apikey id only from the 2nd child, to keep physicalIds of UsagePlanKey for existing CDK apps unmodifed.
const id = this.node.tryFindChild(prefix) ? `${prefix}:${apiKey.node.uniqueId}` : prefix;
const id = this.construct.tryFindChild(prefix) ? `${prefix}:${apiKey.construct.uniqueId}` : prefix;

new CfnUsagePlanKey(this, id, {
keyId: apiKey.keyId,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class VpcLink extends Resource implements IVpcLink {
constructor(scope: Construct, id: string, props: VpcLinkProps = {}) {
super(scope, id, {
physicalName: props.vpcLinkName ||
Lazy.stringValue({ produce: () => this.node.uniqueId }),
Lazy.stringValue({ produce: () => this.construct.uniqueId }),
});

const cfnResource = new CfnVpcLink(this, 'Resource', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class DeployStack extends NestedStack {
const deployment = new Deployment(this, 'Deployment', {
api: RestApi.fromRestApiId(this, 'RestApi', props.restApiId),
});
(props.methods ?? []).forEach((method) => deployment.node.addDependency(method));
(props.methods ?? []).forEach((method) => deployment.construct.addDependency(method));
new Stage(this, 'Stage', { deployment });
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export = {
const dep = new CfnResource(stack, 'MyResource', { type: 'foo' });

// WHEN
deployment.node.addDependency(dep);
deployment.construct.addDependency(dep);

expect(stack).to(haveResource('AWS::ApiGateway::Deployment', {
DependsOn: [
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/test/test.method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export = {
expect(stack).to(haveResource('AWS::ApiGateway::Method', {
HttpMethod: 'GET',
RequestModels: {
'application/json': { Ref: stack.getLogicalId(model.node.findChild('Resource') as cdk.CfnElement) },
'application/json': { Ref: stack.getLogicalId(model.construct.findChild('Resource') as cdk.CfnElement) },
},
}));

Expand Down Expand Up @@ -539,7 +539,7 @@ export = {
ResponseModels: {
'application/json': 'Empty',
'text/plain': 'Error',
'text/html': { Ref: stack.getLogicalId(htmlModel.node.findChild('Resource') as cdk.CfnElement) },
'text/html': { Ref: stack.getLogicalId(htmlModel.construct.findChild('Resource') as cdk.CfnElement) },
},
},
],
Expand Down Expand Up @@ -568,10 +568,10 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::ApiGateway::Method', {
RequestValidatorId: { Ref: stack.getLogicalId(validator.node.findChild('Resource') as cdk.CfnElement) },
RequestValidatorId: { Ref: stack.getLogicalId(validator.construct.findChild('Resource') as cdk.CfnElement) },
}));
expect(stack).to(haveResource('AWS::ApiGateway::RequestValidator', {
RestApiId: { Ref: stack.getLogicalId(api.node.findChild('Resource') as cdk.CfnElement) },
RestApiId: { Ref: stack.getLogicalId(api.construct.findChild('Resource') as cdk.CfnElement) },
ValidateRequestBody: true,
ValidateRequestParameters: false,
}));
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/test/test.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::ApiGateway::Model', {
RestApiId: { Ref: stack.getLogicalId(api.node.findChild('Resource') as cdk.CfnElement) },
RestApiId: { Ref: stack.getLogicalId(api.construct.findChild('Resource') as cdk.CfnElement) },
Schema: {
$schema: 'http://json-schema.org/draft-04/schema#',
title: 'test',
Expand Down Expand Up @@ -61,7 +61,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::ApiGateway::Model', {
RestApiId: { Ref: stack.getLogicalId(api.node.findChild('Resource') as cdk.CfnElement) },
RestApiId: { Ref: stack.getLogicalId(api.construct.findChild('Resource') as cdk.CfnElement) },
Schema: {
$schema: 'http://json-schema.org/draft-04/schema#',
title: 'test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::ApiGateway::RequestValidator', {
RestApiId: { Ref: stack.getLogicalId(api.node.findChild('Resource') as cdk.CfnElement) },
RestApiId: { Ref: stack.getLogicalId(api.construct.findChild('Resource') as cdk.CfnElement) },
ValidateRequestBody: true,
ValidateRequestParameters: false,
}));
Expand All @@ -49,7 +49,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::ApiGateway::RequestValidator', {
RestApiId: { Ref: stack.getLogicalId(api.node.findChild('Resource') as cdk.CfnElement) },
RestApiId: { Ref: stack.getLogicalId(api.construct.findChild('Resource') as cdk.CfnElement) },
Name: 'my-model',
ValidateRequestBody: false,
ValidateRequestParameters: true,
Expand Down
Loading

0 comments on commit 3519d02

Please sign in to comment.