Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: upgrade to constructs 4.x #8962

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3962d35
try to use aliases to reduce blast radius
Jul 8, 2020
fb13655
Dependable.dependencyRoots
Jul 8, 2020
a507b4e
Allow subclasses of CfnResource to customize toCloudFormation()
Jul 8, 2020
b4ec41b
iam
Jul 8, 2020
9cbb189
legacy construct settings if stack is root
Jul 8, 2020
cf49643
fix codepipeline tests
Jul 8, 2020
1f1f449
dependencies => dependencyRoots
Jul 8, 2020
fbcd471
Hoist an "App" when stacks are created as root
Jul 8, 2020
9c65456
step functions
Jul 8, 2020
1b41a31
lambda
Jul 9, 2020
1bcda11
upgrade constructs
Jul 9, 2020
dcf020e
fix README
Jul 9, 2020
91839c4
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 9, 2020
cd6310a
update readme
Jul 9, 2020
4c75d0f
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 9, 2020
de75d9a
progression
Jul 9, 2020
59ad3fd
rename default stack name to "Stack"
Jul 9, 2020
e71e3a7
force resynth in tests
Jul 9, 2020
b4087cc
ec2
Jul 9, 2020
71441ec
some more tests
Jul 9, 2020
743f5c2
version hashes changed because path changed
Jul 9, 2020
469480d
progression
Jul 9, 2020
122a912
use DependencyGroup instead of CompositeDependable
Jul 10, 2020
0ffcd45
more test updates
Jul 10, 2020
e246cc7
more updates
Jul 12, 2020
fef4483
rename "forceResynth" to "force"
Jul 12, 2020
e2ffafa
more test updates
Jul 12, 2020
f7d5d60
progression
Jul 12, 2020
430f742
11 remaining
Jul 12, 2020
dda57ae
additional test fixes
Jul 13, 2020
72dd184
full build+test pass 1st time
Jul 13, 2020
5107ece
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 13, 2020
b205423
upgrade to pre.4
Jul 13, 2020
c418fc9
Revert "chore(core): allow the bundler to re-use pre-existing bundler…
Jul 13, 2020
5c49f05
Merge remote-tracking branch 'origin/benisrae/revert-8916' into benis…
Jul 13, 2020
174f80d
fixes
Jul 13, 2020
ec2e1f0
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 13, 2020
cacd4e7
a couple of fixes
Jul 13, 2020
234a395
fix
Jul 13, 2020
ee40f61
fix a bunch of other tests
Jul 13, 2020
d28e49b
test fixes
Jul 13, 2020
325cc6d
app for root stack must never "autoSynth" and use a temp directory
Jul 13, 2020
358d177
implement "prepare" using aspects
Jul 13, 2020
92c92db
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 13, 2020
8ed2437
disable API compat check
Jul 14, 2020
c1ffedf
Merge remote-tracking branch 'origin/master' into benisrae/constructs…
Jul 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ echo "==========================================================================
echo "building..."
time lerna run $bail --stream $runtarget || fail

/bin/bash scripts/check-api-compatibility.sh
echo "***************************************************************************************************"
echo " API compatibility check is disabled since this is a major version branch"
echo "***************************************************************************************************"
#/bin/bash scripts/check-api-compatibility.sh

touch $BUILD_INDICATOR
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"pack": "./pack.sh",
"compat": "./scripts/check-api-compatibility.sh",
"bump": "./bump.sh",
"build-all": "tsc -b"
"watch-all": "./scripts/build-typescript.sh -w",
"build-all": "./scripts/build-typescript.sh"
},
"devDependencies": {
"conventional-changelog-cli": "^2.0.34",
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
},
"dependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';

export interface PipelineDeployStackActionProps {
/**
Expand Down Expand Up @@ -147,7 +148,7 @@ export class PipelineDeployStackAction implements codepipeline.IAction {
});
}

public bind(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
public bind(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
codepipeline.ActionConfig {
if (this.stack.environment !== cdk.Stack.of(scope).environment) {
// FIXME: Add the necessary to extend to stacks in a different account
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
Expand Down Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as iam from '@aws-cdk/aws-iam';
import * as s3 from '@aws-cdk/aws-s3';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as fc from 'fast-check';
import * as nodeunit from 'nodeunit';
import { PipelineDeployStackAction } from '../lib/pipeline-deploy-stack-action';
Expand Down Expand Up @@ -459,7 +460,7 @@ class FakeAction implements codepipeline.IAction {
this.outputArtifact = new codepipeline.Artifact('OutputArtifact');
}

public bind(_scope: cdk.Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions):
public bind(_scope: Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions):
codepipeline.ActionConfig {
return {};
}
Expand Down
32 changes: 23 additions & 9 deletions packages/@aws-cdk/assert/lib/synth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import * as core from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';

export class SynthUtils {
/**
* Returns the cloud assembly template artifact for a stack.
*/
public static synthesize(stack: core.Stack, options: core.SynthesisOptions = { }): cxapi.CloudFormationStackArtifact {
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
const root = stack.node.root;

// if the root is an app, invoke "synth" to avoid double synthesis
const assembly = root instanceof core.App ? root.synth() : core.ConstructNode.synth(root.node, options);

const assembly = synthesizeApp(stack, options);
return assembly.getStackArtifact(stack.artifactId);
}

Expand Down Expand Up @@ -51,10 +50,7 @@ export class SynthUtils {
*/
public static _synthesizeWithNested(stack: core.Stack, options: core.SynthesisOptions = { }): cxapi.CloudFormationStackArtifact | object {
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
const root = stack.node.root;

// if the root is an app, invoke "synth" to avoid double synthesis
const assembly = root instanceof core.App ? root.synth() : core.ConstructNode.synth(root.node, options);
const assembly = synthesizeApp(stack, options);

// if this is a nested stack (it has a parent), then just read the template as a string
if (stack.nestedStackParent) {
Expand All @@ -65,6 +61,24 @@ 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;
if (!core.Stage.isStage(root)) {
throw new Error('unexpected: all stacks must be part of a Stage or an App');
}

// to support incremental assertions (i.e. "expect(stack).toNotContainSomething(); doSomething(); expect(stack).toContainSomthing()")
const force = true;

return root.synth({
force,
...options,
});
}

export interface SubsetOptions {
/**
* Match all resources of the given type
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"jest": "^25.5.4",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"repository": {
"url": "https://github.com/aws/aws-cdk.git",
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/assert/test/assertions.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cdk from '@aws-cdk/core';
import * as cx from '@aws-cdk/cx-api';

import { Construct } from 'constructs';
import { countResources, countResourcesLike, exist, expect as cdkExpect, haveType, MatchStyle, matchTemplate } from '../lib/index';

passingExample('expect <synthStack> at <some path> to have <some type>', () => {
Expand Down Expand Up @@ -332,7 +333,7 @@ interface TestResourceProps extends cdk.CfnResourceProps {
}

class TestResource extends cdk.CfnResource {
constructor(scope: cdk.Construct, id: string, props: TestResourceProps) {
constructor(scope: Construct, id: string, props: TestResourceProps) {
super(scope, id, props);
}
}
Expand All @@ -342,7 +343,7 @@ interface TestParameterProps extends cdk.CfnParameterProps {
}

class TestParameter extends cdk.CfnParameter {
constructor(scope: cdk.Construct, id: string, props: TestParameterProps) {
constructor(scope: Construct, id: string, props: TestParameterProps) {
super(scope, id, props);
}
}
3 changes: 2 additions & 1 deletion packages/@aws-cdk/assets/lib/staging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AssetStaging, Construct } from '@aws-cdk/core';
import { AssetStaging } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { toSymlinkFollow } from './compat';
import { FingerprintOptions } from './fs/options';

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
"dependencies": {
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
6 changes: 4 additions & 2 deletions packages/@aws-cdk/assets/test/test.staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Staging } from '../lib';
export = {
'base case'(test: Test) {
// GIVEN
const stack = new Stack();
const app = new App();
const stack = new Stack(app, 'test');
const sourcePath = path.join(__dirname, 'fs', 'fixtures', 'test1');

// WHEN
Expand All @@ -22,7 +23,8 @@ export = {

'staging can be disabled through context'(test: Test) {
// GIVEN
const stack = new Stack();
const app = new App();
const stack = new Stack(app, 'test');
stack.node.setContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT, true);
const sourcePath = path.join(__dirname, 'fs', 'fixtures', 'test1');

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
},
"dependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-acmpca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
},
"dependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
},
"dependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as codebuild from '@aws-cdk/aws-codebuild';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, IResource, Lazy, Resource, SecretValue } from '@aws-cdk/core';
import { IResource, Lazy, Resource, SecretValue } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApp } from './amplify.generated';
import { BasicAuth } from './basic-auth';
import { Branch, BranchOptions } from './branch';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/lib/basic-auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as kms from '@aws-cdk/aws-kms';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { Construct, SecretValue } from '@aws-cdk/core';
import { SecretValue } from '@aws-cdk/core';
import { Construct } from 'constructs';

/**
* Properties for a BasicAuth
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/lib/branch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as codebuild from '@aws-cdk/aws-codebuild';
import { Construct, IResource, Lazy, Resource } from '@aws-cdk/core';
import { IResource, Lazy, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnBranch } from './amplify.generated';
import { IApp } from './app';
import { BasicAuth } from './basic-auth';
Expand Down
10 changes: 8 additions & 2 deletions packages/@aws-cdk/aws-amplify/lib/domain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Lazy, Resource } from '@aws-cdk/core';
import { Lazy, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDomain } from './amplify.generated';
import { IApp } from './app';
import { IBranch } from './branch';
Expand Down Expand Up @@ -91,6 +92,8 @@ export class Domain extends Resource {
this.domainName = domain.attrDomainName;
this.domainStatus = domain.attrDomainStatus;
this.statusReason = domain.attrStatusReason;

this.node.addValidation({ validate: () => this.validateDomain() });
}

/**
Expand All @@ -111,7 +114,10 @@ export class Domain extends Resource {
return this.mapSubDomain(branch, '');
}

protected validate() {
/**
* IValidation implementation.
*/
private validateDomain() {
if (this.subDomains.length === 0) {
return ['The domain doesn\'t contain any subdomains'];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@aws-cdk/aws-codecommit": "0.0.0",
"@aws-cdk/aws-secretsmanager": "0.0.0",
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"peerDependencies": {
"@aws-cdk/aws-iam": "0.0.0",
Expand All @@ -87,7 +87,7 @@
"@aws-cdk/aws-codecommit": "0.0.0",
"@aws-cdk/aws-secretsmanager": "0.0.0",
"@aws-cdk/core": "0.0.0",
"constructs": "^3.0.2"
"constructs": "4.1.1-pre.4"
},
"engines": {
"node": ">= 10.13.0 <13 || >=13.7.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as codecommit from '@aws-cdk/aws-codecommit';
import { App, Construct, Stack, StackProps } from '@aws-cdk/core';
import { App, Stack, StackProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as amplify from '../lib';

class TestStack extends Stack {
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/test/integ.app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { App, Construct, Stack, StackProps } from '@aws-cdk/core';
import { App, Stack, StackProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as amplify from '../lib';

class TestStack extends Stack {
Expand Down
Loading