title: How to wait stack to complete before executing code in AWS CDK?
body: <p>I'm trying AWS CDK and got stuck when I tried to execute a code block that depends on the stack completion.</p>
  
  <p>Here's my current code:</p>
  
  <pre class="lang-js prettyprint-override"><code>class Application extends cdk.Construct {
      constructor(scope: cdk.Construct, id: string) {
          super(scope, id);
          const webStack = new WebsiteStack(app, `website-stack-${id}`, { stage: id })
          const buildStack = new CodeBuildStack(app, `codebuild-stack-${id}`, { stage:id, bucket: webStack.websiteBucket, distribution: webStack.websiteDistribution });
          this.generateBuildParameter(id, webStack, buildStack)
      }
  
      generateBuildParameter(id: string, webStack: WebsiteStack, buildStack: CodeBuildStack) {
          const buildParam = {
              projectName: buildStack.buildProject.projectName,
              sourceVersion: id,
              environmentVariablesOverride: [
                { name: "STAGE", value: id, type: "PLAINTEXT" },
                { name: "WEBSITE_BUCKET", value: webStack.websiteBucket.bucketName, type: "PLAINTEXT" },
                { name: "CLOUDFRONT_DISTRIBUTION_ID", value: webStack.websiteDistribution.distributionId, "type": "PLAINTEXT" }
              ],
              buildspecOverride: "./buildspec.yml"
          }
          fse.outputJson(`./cdk.out/build-parameters/build-${id}.json`, buildParam, (err: Error) =&gt; {
              if (err) {
                  throw err
              };
              console.log(`build parameter has been created in "../cdk.out/build-parameters/build-${id}.json"`);
          })
      }
  }
  </code></pre>
  
  <p>I'm just trying to generate a json file that depends on the <code>buildStack</code>. However, it seems that it's not waiting for the stack to complete.</p>
  
  <p>Here's my current output:</p>
  
  <pre><code>{
     "projectName":"${Token[TOKEN.41]}",
     "sourceVersion":"master",
     "environmentVariablesOverride":[{"name":"STAGE","value":"master","type":"PLAINTEXT"},{"name":"WEBSITE_BUCKET","value":"${Token[TOKEN.17]}","type":"PLAINTEXT"},{"name":"CLOUDFRONT_DISTRIBUTION_ID","value":"${Token[TOKEN.26]}","type":"PLAINTEXT"}],
     "buildspecOverride":"./buildspec.yml"
  }
  </code></pre>
  
  <p>Does AWS CDK support Promise or some sort to wait the stack to be completed?</p>