Skip to content

feat(core): the "constructs" module#6623

Merged
mergify[bot] merged 34 commits intomasterfrom
benisrae/extract-constructs
Mar 17, 2020
Merged

feat(core): the "constructs" module#6623
mergify[bot] merged 34 commits intomasterfrom
benisrae/extract-constructs

Conversation

@eladb
Copy link
Contributor

@eladb eladb commented Mar 8, 2020

Core review pointers:

TODO:

Commit Message

feat(core): the "constructs" module (#6623)

This commit extracts the constructs programming model into an independent library called constructs (npm, Maven, PyPI, NuGet). This library includes the Construct base class (and satellites) as well as the token system. The main motivation is to enable projects like CDK for Kubernetes to reuse these building blocks and allow interoperability between the frameworks (hence they have to use the same base types).

To ensure backwards compatibility until we release v2.0 of the AWS CDK, the construct-compat.ts file implements shadow and wrapper types for types that are now in "constructs" so the AWS CDK code remains unchanged and fully passes API compatibility tests.

The token system and a bunch of types related to dependencies has been duplicated since the effort of shadowing was too great and there is no major value (it would still be possible to interoperate even if we have two token systems).

Added an additional dependency on constructs to all AWS CDK modules.

MONOCDK: has been modified to take a peerDependency on this new module as this will be the final setup (users will have to depend on both monocdk and constructs), so we are not going to take shortcuts here.

TESTING: All relevant unit tests were duplicated from @aws-cdk/core to constructs, and intentionally maintained unchanged in core to ensure backwards compatibility.

End Commit Message

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

This commit extracts the constructs programming model into an independent library called `constructs`. This library includes the Construct base class (and satellites) as well as the token system. The main motivation is to enable projects like [CDK for Kubernetes] to reuse these building blocks and allow interoperability between the frameworks (hence they have to use the same base types).

To ensure backwards compatibility until we release v2.0 of the AWS CDK, the `constructs-compat.ts` file implements shadow and wrapper types for types that are now in "constructs" so the AWS CDK code remains unchanged and fully passes API compatibility tests.

The token system and a bunch of types related to dependencies has been _duplicated_ since the effort of shadowing was too great and there is no major value (it would still be possible to interoperate even if we have two token systems).

[CDK for Kubernetes]: https://github.com/awslabs/cdk8s
@eladb eladb changed the title feat(core): constructs library feat(core): the "constructs" library Mar 8, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 8, 2020
@eladb eladb requested a review from a team March 8, 2020 12:45
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 1f012d9
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 2ef9f19
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Elad Ben-Israel added 3 commits March 8, 2020 14:50
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: dc19216
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 7c6559a
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 971faa3
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e4b2349
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 1c5b490
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Elad Ben-Israel added 2 commits March 8, 2020 17:41
Since we rely on peer dependencies it's not needed any longer and also conflicts with the one we already have in @aws-cdk/core, so it's a good opportunity to get rid of it.
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f7ae5ac
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: ceebff2
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@eladb eladb changed the title feat(core): the "constructs" library feat(core): the "constructs" module Mar 8, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c2123a4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@eladb eladb added the pr/do-not-merge This PR should not be merged at this time. label Mar 8, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 197a8d0
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this thing is cray-cray to review :)

I imagine synthesis is part of the constructs library as well; what about the cx-api protocol and all the CloudFormation-specific artifacts in there?

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 64119d7
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@eladb eladb added the pr-linter/exempt-readme The PR linter will not require README changes label Mar 16, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 89ba351
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 5c02843
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: fbc36fd
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

eval: e => {
for (const method of e.ctx.directEventMethods.concat(e.ctx.cloudTrailEventMethods)) {
e.assert(!e.ctx.interfaceType || e.ctx.interfaceType.allMethods.some(m => m.name === method.name), `${e.ctx.fqn}.${method.name}`);
e.assert(!e.ctx.interfaceType || e.ctx.interfaceType.allMethods.filter(m => !m.protected).some(m => m.name === method.name), `${e.ctx.fqn}.${method.name}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rix0rrr This is needed because the protected lifecycle methods in constructs.Construct are named onSynthesize, onValidate and onPrepare.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not forcing protected methods to be part of a public interface would always have been the right thing to do anyway, regardless of the change you just made.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: aa3bd84
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b0a75ed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

cd $(mktemp -d)
npm init -y
npm install ${tarball}
npm install ${tarball} constructs@${constructs_version}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this run into bootstrapping problems? Is the construct library already published to NPM at the right version here? What IS the versioning strategy for that even?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already published.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The versioning strategy is that it has it's own semantic version line. Current version is 1.1.2

@rix0rrr
Copy link
Contributor

rix0rrr commented Mar 17, 2020

Wait, the proposed new "constructs" library is not in this PR anymore, is it?

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this.

@rix0rrr
Copy link
Contributor

rix0rrr commented Mar 17, 2020

Oh one more thing: how does the Assembly fit into this? I guess CXAPI is not a dependency of constructs, right? Do we have a generalized constructs.IAssemblyBuilder that cxapi.AssemblyBuilder derives from?

@eladb eladb added the pr-linter/exempt-test The PR linter will not require test changes label Mar 17, 2020
@eladb
Copy link
Contributor Author

eladb commented Mar 17, 2020

Oh one more thing: how does the Assembly fit into this? I guess CXAPI is not a dependency of constructs, right? Do we have a generalized constructs.IAssemblyBuilder that cxapi.AssemblyBuilder derives from?

@rix0rrr I changed the interface of ISynthesisSession in constructs to only include an outdir, and the App construct is actually not included in that library. This makes cloud assemblies an "AWS CDK thing" if that makes sense.

@eladb eladb removed the pr/do-not-merge This PR should not be merged at this time. label Mar 17, 2020
Copy link
Contributor Author

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 97403c1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 628ae39
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Mar 17, 2020

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).

@mergify mergify bot merged commit eded95b into master Mar 17, 2020
@mergify mergify bot deleted the benisrae/extract-constructs branch March 17, 2020 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants