lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js/configurePreflightMethods
    const configurePreflightMethods = (corsConfig, logicalIds) => {
      const preflightMethods = {};

      _.forOwn(corsConfig, (config, path) => {
        const resourceLogicalId = logicalIds[path];

        const preflightHeaders = {
          'Access-Control-Allow-Origin': `'${config.origins.join(',')}'`,
          'Access-Control-Allow-Headers': `'${config.headers.join(',')}'`,
          'Access-Control-Allow-Methods': `'${config.methods.join(',')}'`,
        };

        const preflightMethodResponse = generateMethodResponseHeaders(preflightHeaders);
        const preflightIntegrationResponse = generateIntegrationResponseHeaders(preflightHeaders);

        const preflightTemplate = `
          {
            "Type" : "AWS::ApiGateway::Method",
            "Properties" : {
              "AuthorizationType" : "NONE",
              "HttpMethod" : "OPTIONS",
              "MethodResponses" : [
                {
                  "ResponseModels" : {},
                  "ResponseParameters" : ${JSON.stringify(preflightMethodResponse)},
                  "StatusCode" : "200"
                }
              ],
              "RequestParameters" : {},
              "Integration" : {
                "Type" : "MOCK",
                "RequestTemplates" : {
                  "application/json": "{statusCode:200}"
                },
                "IntegrationResponses" : [
                  {
                    "StatusCode" : "200",
                    "ResponseParameters" : ${JSON.stringify(preflightIntegrationResponse)},
                    "ResponseTemplates" : {
                      "application/json": ""
                    }
                  }
                ]
              },
              "ResourceId" : { "Ref": "${resourceLogicalId}" },
              "RestApiId" : { "Ref": "ApiGatewayRestApi" }
            }
          }
        `;
        const extractedResourceId = resourceLogicalId.match(/ApiGatewayResource(.*)/)[1];

        _.merge(preflightMethods, {
          [`ApiGatewayMethod${extractedResourceId}Options`]:
            JSON.parse(preflightTemplate),
        });
      });

      return preflightMethods;
    };