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

fix(core): DefaultSynthesizer breaks this.node.setContext() on Stack #10246

Merged
merged 6 commits into from
Sep 9, 2020

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Sep 8, 2020

Since the DefaultSynthesizer recently started adding constructs into
the Stack at construction time, that broke this.node.setContext()
which requires that no children have been added to a construct yet
when its context is being modified.

To fix this, add the constructs just-in-time just before the stack
is being synthesized.

In order to give the DefaultStackSynthesizer a chance to modify
the stack's construct tree before its template is being written out,
the Synthesizer is now in full control of the order in which things
happen.

Change the call tree from:

synthesizeTree
  - stack._synthesizeTemplate
      - (write template)
      - this.synthesizer.synthesizeStackArtifacts
          - (register artifacts)

To:

synthesizeTree
  - stack.synthesizer.synthesize
      - stack._synthesizeTemplate
          - (write template)
      - (register artifacts)

All APIs involved in this call tree are either @experimental or
@internal.

BREAKING CHANGE: custom implementations of IStackSynthesizer
must now implement synthesize() instead of
synthesizeStackArtifacts().


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

Since the `DefaultSynthesizer` recently started adding constructs into
the Stack at construction time, that broke `this.node.setContext()`
which requires that no children have been added to a construct yet
when its context is being modified.

To fix this, add the constructs just-in-time just before the stack
is being synthesized.

In order to give the `DefaultStackSynthesizer` a chance to modify
the stack's construct tree before its template is being written out,
the Synthesizer is now in full control of the order in which things
happen.

Change the call tree from:

```
synthesizeTree
  - stack._synthesizeTemplate
      - (write template)
      - this.synthesizer.synthesizeStackArtifacts
          - (register artifacts)
```

To:

```
synthesizeTree
  - stack.synthesizer.synthesize
      - stack._synthesizeTemplate
          - (write template)
      - (register artifacts)
```

All APIs involved in this call tree are either `@experimental` or
`@internal`.

BREAKING CHANGE: custom implementations of `IStackSynthesizer`
must now implement `synthesize()` instead of
`synthesizeStackArtifacts()`.
@rix0rrr rix0rrr requested a review from a team September 8, 2020 12:51
@rix0rrr rix0rrr self-assigned this Sep 8, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 8, 2020
assertBound(this.stack);

this.stack._synthesizeTemplate(session);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to relay back to Stack? Maybe we can just move all the code into here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_synthesizeTemplate is accessing all private members. This feels cleaner than exposing those.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@mergify
Copy link
Contributor

mergify bot commented Sep 9, 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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 40d5e04
  • 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 Sep 9, 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 61865aa into master Sep 9, 2020
@mergify mergify bot deleted the huijbers/stack-context branch September 9, 2020 09:53
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants