title: AWS CDK passing API Gateway URL to static site in same Stack
body: <p>I'm trying to deploy an S3 static website and API gateway/lambda in a single stack.</p>
  
  <p>The javascript in the S3 static site calls the lambda to populate an HTML list but it needs to know the API Gateway URL for the lambda integration.</p>
  
  <p>Currently, I generate a RestApi like so...</p>
  
  <pre><code>    const handler = new lambda.Function(this, "TestHandler", {
        runtime: lambda.Runtime.NODEJS_10_X,
        code: lambda.Code.asset("build/test-service"),
        handler: "index.handler",
        environment: {
        }
      });
  
      this.api = new apigateway.RestApi(this, "test-api", {
        restApiName: "Test Service"
      });    
  
      const getIntegration = new apigateway.LambdaIntegration(handler, {
        requestTemplates: { "application/json": '{ "statusCode": "200" }' }
      });
  
      const apiUrl = this.api.url;
  </code></pre>
  
  <p>But on cdk deploy, apiUrl = </p>
  
  <p><code>"https://${Token[TOKEN.39]}.execute-api.${Token[AWS::Region.4]}.${Token[AWS::URLSuffix.1]}/${Token[TOKEN.45]}/"</code></p>
  
  <p>So the url is not parsed/generated until after the static site requires the value.</p>
  
  <p>How can I calculate/find/fetch the API Gateway URL and update the javascript on cdk deploy?</p>
  
  <p>Or is there a better way to do this?  i.e. is there a graceful way for the static javascript to retrieve a lambda api gateway url?</p>
  
  <p>Thanks.</p>