title: enabling CORS for AWS API gateway with the AWS CDK
body: <p>I'm trying to build an application with the AWS CDK and if I were to build an application by hand using the AWS Console, I normally would enable CORS in API gateway.</p>
  
  <p>Even though I can export the swagger out of API Gateway and have found numerous options to generate a Mock endpoint for the OPTIONS method I don't see how to do this with the CDK.  Currently I was trying: </p>
  
  <pre><code>const apigw             = require('@aws-cdk/aws-apigateway');
  </code></pre>
  
  <p>where: </p>
  
  <pre><code>var api                 = new apigw.RestApi(this, 'testApi');
  </code></pre>
  
  <p>and defining the OPTIONS method like:</p>
  
  <pre><code>const testResource   = api.root.addResource('testresource');
  
  var mock = new apigw.MockIntegration({
                      type: "Mock",
                      methodResponses: [
                              {
                                      statusCode: "200",
                                      responseParameters : {
                                              "Access-Control-Allow-Headers" : "string",
                                              "Access-Control-Allow-Methods" : "string",
                                              "Access-Control-Allow-Origin" : "string"
                                      }
                              }
                      ],
                      integrationResponses: [
                              {
                                      statusCode: "200",
                                      responseParameters: {
                                              "Access-Control-Allow-Headers" :  "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
                                              "Access-Control-Allow-Origin" : "'*'",
                                              "Access-Control-Allow-Methods" : "'GET,POST,OPTIONS'"
                                      }
                              }
                      ],
                      requestTemplates: {
                              "application/json": "{\"statusCode\": 200}"
                      }
              });
  
              testResource.addMethod('OPTIONS', mock);
  </code></pre>
  
  <p>But this doesn't deploy.   The error message I get from the cloudformation stack deploy when I run "cdk deploy" is:</p>
  
  <pre><code>Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression specified: Access-Control-Allow-Origin] (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;
  </code></pre>
  
  <p>Ideas?</p>