You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Toolkit communicates with the CDK app passing environment variables
(containing context, and others).
If the CDK app is executed as a subprocess it is trivial to set those
environment variables when executing the subprocess; but for an
in-memory synthesis as allowed by `fromAssemblyBuilder` mutating
`process.env` is not the correct approach: it is clobbering global
state, and multiple async assembly builders might fight with each other
over the single shared global object.
At the same time, it is *extreeeeeemely* convenient for an app author to
not have to think about passing props.
So we leave the current behavior as a convenient default, but add the
option `clobberEnv: false` to explicitly disable this.
In `fromAssemblyBuilder()`, we now pass an additional `env` prop
containing the environment variables we applied (or didn't). There were
already parametes for `outdir` and `context`; with `clobberEnv: false`
those *must* now be passed to an `App` instantiated inside the builder
(whereas otherwise the `App` will pick up on the globally mutated
`process.env` changes).
The rest of this PR is reorganizing the code to make the code that
touches the environment return values instead of directly applying them.
* Remove `withEnv()` and `withContext()`.
* Move logging of the final context object out to the call site instead
of the builder function.
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
0 commit comments