Skip to content

Commit

Permalink
refactor(util): remove @aws-cdk/util (#745)
Browse files Browse the repository at this point in the history
@aws-cdk/util is barely used, and caused some issues related
to bundled dependencies.

Moved the code and tests to aws-cdk, which is the primary user.

Fixes #709

BREAKING CHANGE: @aws-cdk/util is no longer available
  • Loading branch information
Elad Ben-Israel authored Sep 27, 2018
1 parent d152a0f commit 10015cb
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 350 deletions.
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-codepipeline-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
"dependencies": {
"@aws-cdk/aws-events": "^0.9.2",
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2",
"@aws-cdk/util": "^0.9.2"
"@aws-cdk/cdk": "^0.9.2"
},
"bundledDependencies": [
"@aws-cdk/util"
],
"homepage": "https://github.com/awslabs/aws-cdk"
}
25 changes: 14 additions & 11 deletions packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import util = require('@aws-cdk/util');
import { cloudformation } from './codepipeline.generated';
import { CommonStageProps, Stage, StagePlacement } from './stage';

Expand Down Expand Up @@ -204,10 +203,10 @@ export class Pipeline extends cdk.Construct implements events.IEventRuleTarget {
* @override
*/
public validate(): string[] {
return util.flatten([
this.validateHasStages(),
this.validateSourceActionLocations()
]);
return [
...this.validateHasStages(),
...this.validateSourceActionLocations()
];
}

/**
Expand Down Expand Up @@ -292,12 +291,16 @@ export class Pipeline extends cdk.Construct implements events.IEventRuleTarget {
}

private validateSourceActionLocations(): string[] {
return util.flatMap(this.stages, (stage, i) => {
const onlySourceActionsPermitted = i === 0;
return util.flatMap(stage.actions, (action, _) =>
actions.validateSourceAction(onlySourceActionsPermitted, action.category, action.id, stage.id)
);
});
const errors = new Array<string>();
let firstStage = true;
for (const stage of this.stages) {
const onlySourceActionsPermitted = firstStage;
for (const action of stage.actions) {
errors.push(...actions.validateSourceAction(onlySourceActionsPermitted, action.category, action.id, stage.id));
}
firstStage = false;
}
return errors;
}

private validateHasStages(): string[] {
Expand Down
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-codepipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@
"@aws-cdk/aws-events": "^0.9.2",
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/aws-s3": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2",
"@aws-cdk/util": "^0.9.2"
"@aws-cdk/cdk": "^0.9.2"
},
"bundledDependencies": [
"@aws-cdk/util"
],
"homepage": "https://github.com/awslabs/aws-cdk"
}
7 changes: 3 additions & 4 deletions packages/@aws-cdk/aws-ec2/lib/vpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cdk = require('@aws-cdk/cdk');
import { Obj } from '@aws-cdk/util';
import { cloudformation } from './ec2.generated';
import { NetworkBuilder } from './network-util';
import { DEFAULT_SUBNET_NAME, subnetId } from './util';
Expand Down Expand Up @@ -252,7 +251,7 @@ export class VpcNetwork extends VpcNetworkRef implements cdk.ITaggable {
/**
* Mapping of NatGateway by AZ
*/
private natGatewayByAZ: Obj<string> = {};
private natGatewayByAZ: { [az: string]: string } = {};

/**
* Subnet configurations for this VPC
Expand Down Expand Up @@ -530,7 +529,7 @@ export class VpcPublicSubnet extends VpcSubnet {
/**
* Creates a new managed NAT gateway attached to this public subnet.
* Also adds the EIP for the managed NAT.
* Returns the NAT Gateway ref
* @returns A ref to the the NAT Gateway ID
*/
public addNatGateway() {
// Create a NAT Gateway in this public subnet
Expand All @@ -541,7 +540,7 @@ export class VpcPublicSubnet extends VpcSubnet {
}).eipAllocationId,
tags: new cdk.TagManager(this),
});
return ngw.ref;
return ngw.natGatewayId;
}
}

Expand Down
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
},
"dependencies": {
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2",
"@aws-cdk/util": "^0.9.2"
"@aws-cdk/cdk": "^0.9.2"
},
"bundledDependencies": [
"@aws-cdk/util"
],
"homepage": "https://github.com/awslabs/aws-cdk"
}
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
},
"dependencies": {
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2",
"@aws-cdk/util": "^0.9.2"
"@aws-cdk/cdk": "^0.9.2"
},
"bundledDependencies": [
"@aws-cdk/util"
],
"homepage": "https://github.com/awslabs/aws-cdk"
}
23 changes: 8 additions & 15 deletions packages/@aws-cdk/aws-quickstarts/lib/database.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ec2 = require('@aws-cdk/aws-ec2');
import rds = require('@aws-cdk/aws-rds');
import cdk = require('@aws-cdk/cdk');
import util = require('@aws-cdk/util');

export interface SqlServerProps {
instanceClass?: string;
Expand Down Expand Up @@ -34,22 +33,16 @@ export class SqlServer extends cdk.Construct implements ec2.IConnectable {
dbSubnetGroupDescription: 'Database subnet group',
});

const p = util.applyDefaults(props, {
instanceClass: 'db.m4.large',
engine: 'sqlserver-se',
engineVersion: '13.00.4422.0.v1',
licenseModel: 'license-included',
allocatedStorage: 200
});
const allocatedStorage = props.allocatedStorage !== undefined ? props.allocatedStorage : 200;

new rds.cloudformation.DBInstanceResource(this, 'Resource', {
allocatedStorage: p.allocatedStorage.toString(),
dbInstanceClass: p.instanceClass,
engine: p.engine,
engineVersion: p.engineVersion,
licenseModel: p.licenseModel,
masterUsername: p.masterUsername,
masterUserPassword: p.masterPassword,
allocatedStorage: allocatedStorage.toString(),
dbInstanceClass: props.instanceClass || 'db.m4.large',
engine: props.engine || 'sqlserver-se',
engineVersion: props.engineVersion || '13.00.4422.0.v1',
licenseModel: props.licenseModel || 'license-included',
masterUsername: props.masterUsername,
masterUserPassword: props.masterPassword,
port: SqlServer.PORT.toString(),
dbSubnetGroupName: subnetGroup.ref,
vpcSecurityGroups: [ securityGroup.securityGroupId ]
Expand Down
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-quickstarts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
"@aws-cdk/aws-ec2": "^0.9.2",
"@aws-cdk/aws-iam": "^0.9.2",
"@aws-cdk/aws-rds": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2",
"@aws-cdk/util": "^0.9.2"
"@aws-cdk/cdk": "^0.9.2"
},
"bundledDependencies": [
"@aws-cdk/util"
],
"homepage": "https://github.com/awslabs/aws-cdk"
}
10 changes: 0 additions & 10 deletions packages/@aws-cdk/util/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions packages/@aws-cdk/util/.npmignore

This file was deleted.

Loading

0 comments on commit 10015cb

Please sign in to comment.