Skip to content

Commit

Permalink
Merge pull request #354 from aws-quickstart/bugfix/builder-cdk-upgrade
Browse files Browse the repository at this point in the history
fixed partial initialization of builder and upgraded to cdk v 2.20.0
  • Loading branch information
shapirov103 authored Apr 12, 2022
2 parents f8a70f0 + 5da6cab commit 1358c35
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ aws --version
Install CDK matching the current version of the Blueprints QuickStart (which can be found in package.json).

```bash
npm install -g aws-cdk@2.17.0
npm install -g aws-cdk@2.20.0
```

Verify the installation.

```bash
cdk --version
# must output 2.17.0
# must output 2.20.0
```

Create a new CDK project. We use `typescript` for this example.
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ aws --version
Install CDK matching the current version of the Blueprints QuickStart (which can be found in package.json).

```bash
npm install -g aws-cdk@2.17.0
npm install -g aws-cdk@2.20.0
```

Verify the installation.

```bash
cdk --version
# must output 2.17.0
# must output 2.20.0
```

Create a new CDK project. We use `typescript` for this example.
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ To use the `eks-blueprints` module, you must have [Node.js](https://nodejs.org/e
Create a directory that represents you project (e.g. `my-blueprints`) and then create a new `typescript` CDK project in that directory.

```bash
npm install -g aws-cdk@2.17.0 # may require sudo (Ubuntu) depending on configuration
cdk --verson # must produce 2.17.0
npm install -g aws-cdk@2.20.0 # may require sudo (Ubuntu) depending on configuration
cdk --verson # must produce 2.20.0
mkdir my-blueprints
cd my-blueprints
cdk init app --language typescript
Expand Down
2 changes: 1 addition & 1 deletion lib/pipelines/code-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class CodePipeline {
input: cdkpipelines.CodePipelineSource.gitHub(`${props.owner}/${props.repository.repoUrl}`, branch, githubProps),
installCommands: [
'npm install --global npm',
'npm install -g aws-cdk@2.17.0',
'npm install -g aws-cdk@2.20.0',
'npm install',
],
commands: ['npm run build', 'npx cdk synth']
Expand Down
8 changes: 4 additions & 4 deletions lib/stacks/eks-blueprint-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class EksBlueprintProps {
*/
export class BlueprintBuilder implements spi.AsyncStackBuilder {

private props: Partial<EksBlueprintProps>;
private env: {
props: Partial<EksBlueprintProps>;
env: {
account?: string,
region?: string
};
Expand All @@ -80,7 +80,7 @@ export class BlueprintBuilder implements spi.AsyncStackBuilder {
this.props = { ...this.props, ...{ name } };
return this;
}

public account(account?: string): this {
this.env.account = account;
return this;
Expand All @@ -103,7 +103,7 @@ export class BlueprintBuilder implements spi.AsyncStackBuilder {

public withBlueprintProps(props: Partial<EksBlueprintProps>): this {
const resourceProviders = this.props.resourceProviders!;
this.props = lodash.cloneDeep(props);
this.props = { ...this.props, ...lodash.cloneDeep(props)};
if(props.resourceProviders) {
this.props.resourceProviders = new Map([...resourceProviders!.entries(), ...props.resourceProviders.entries()]);
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-quickstart/eks-blueprints",
"version": "0.1.3",
"version": "0.1.4",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -18,7 +18,7 @@
"@types/node": "^16.11.13",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"aws-cdk": "2.17.0",
"aws-cdk": "2.20.0",
"copyfiles": "^2.4.1",
"eslint": "^8.4.1",
"jest": "^27.4.7",
Expand All @@ -30,7 +30,7 @@
"@types/assert": "^1.5.6",
"@types/bcrypt": "^5.0.0",
"@types/lodash": "^4.14.180",
"aws-cdk-lib": "2.17.0",
"aws-cdk-lib": "2.20.0",
"aws-sdk": "2.1069.0",
"bcrypt": "^5.0.1",
"dot-object": "^2.1.4",
Expand Down
21 changes: 20 additions & 1 deletion test/stacks.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CapacityType } from 'aws-cdk-lib/aws-eks';
import { CapacityType, KubernetesVersion } from 'aws-cdk-lib/aws-eks';
import * as cdk from 'aws-cdk-lib';
import { ManualApprovalStep } from 'aws-cdk-lib/pipelines';
import * as blueprints from '../lib';
Expand Down Expand Up @@ -237,6 +237,25 @@ test("Generic cluster provider correctly registers managed node groups", async (
expect(blueprint.getClusterInfo().nodeGroups!.length).toBe(2);
});

test("Building blueprint with builder properly clones properties", () => {
const blueprint = blueprints.EksBlueprint.builder().name("builer-test1")
.addOns(new blueprints.AppMeshAddOn);
expect(blueprint.props.addOns).toHaveLength(1);

blueprint.withBlueprintProps({
version: KubernetesVersion.V1_21
});

expect(blueprint.props.addOns).toHaveLength(1);

const blueprint1 = blueprint.clone();
blueprint1.addOns(new blueprints.ArgoCDAddOn);

expect(blueprint.props.addOns).toHaveLength(1);
expect(blueprint1.props.addOns).toHaveLength(2);

});

function assertBlueprint(stack: blueprints.EksBlueprint, ...charts: string[]) {
const template = Template.fromStack(stack);
for (let chart of charts) {
Expand Down

0 comments on commit 1358c35

Please sign in to comment.