Haider Abbas
01/25/2022, 12:20 PMOPTIONS /resources/post-here/ HTTP/1.1
Host: bar.example
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Connection: keep-alive
Origin: <https://foo.example>
Access-Control-Request-Method: POST
Access-Control-Request-Headers: X-PINGOTHER, Content-Type
Any help on this would mean a lot for me. Great Thanks!İsmail Eğilmez
01/25/2022, 1:19 PMOmi Chowdhury
01/25/2022, 3:50 PMAccess-Control-Request-Headers
Frank
Frank
Api
construct?Haider Abbas
01/25/2022, 8:19 PM'use strict';
import AWS from 'aws-sdk';
import { DB, getDatabasePassword } from './db-handler';
import { IClientDetailsRow } from './interfaces/client-details-row.interface';
import { internalErrorResponse, successResponse } from './response';
const DB_PORT = '3306';
const DB_CHARSET = 'utf8mb4';
const CLUSTER_CREATE_THRESHOLD = '15';
const INSTANCE_CREATE_THRESHOLD = '45';
const S3_POLICY_WAIT_THRESHOLD = '15';
const JOB_SPIN_UP_NEW_TENANT_DEF_NAME = 'admin-tasks';
const JOB_SPIN_UP_NEW_TENANT_Q_NAME = 'admin-tasks';
const AWS_ACCOUNT_NUMBER = process.env.AWS_ACCOUNT_NUMBER;
const submitHandler = async (countkey: string, context, callback) => {
console.log('IN submitHandler');
const arnList = (context.invokedFunctionArn).split(':');
const region: string = arnList[3];
console.log(`arnList: ${arnList}; region: ${region}`);
return await getClientDetails(countkey)
.then(async (clientDetails: IClientDetailsRow) => {
return await createEcsClusterIfItDoesNotExist(region, clientDetails,
callback);
})
.catch((error) => {
console.log(error);
return callback('ERROR: Get client details call failed', internalErrorResponse());
});
};
Haider Abbas
01/25/2022, 8:20 PMimport { customerSetup, submitJob } from './handler';
import {
healthCheckResponse,
internalErrorResponse,
optionsResponse,
routeNotFoundResponse
} from './response';
export const lambdaHandler = async (event: any, context: any, callback: any) => {
console.log(event);
return await getRoute(event, context, callback);
};
const getRoute = async (event: any, context: any, callback: any) => {
try {
console.log('IN getRoute');
const requestVerb = `${event['requestContext']['http']['method']}`;
console.log(`requestVerb ${requestVerb}`);
if (requestVerb === 'OPTIONS') {
console.log('IN OPTIONS response');
console.log(optionsResponse());
return callback(null, optionsResponse());
}
const pathParameters = `${event['pathParameters']['proxy']}`.toLowerCase();
const path = `${requestVerb} ${pathParameters}`;
console.log(`path: ${path}`);
switch (path) {
case 'POST submitjob':
console.log('IN submitJob case');
return await submitJob(event, context, callback);
case 'POST customer_setup':
return await customerSetup(event, context, callback);
// case 'POST deleteCustomer':
// // TODO: Get proper object off of event to make this work
// // Was not wired up before, so need to reattach
// // And this needs to be protected/authenticated.
// const companyDomainName = event.message.rds_host;
// return await deleteCluster('us-east-1', companyName, callback);
case 'GET healthcheck':
return callback(null, healthCheckResponse());
default:
return callback(null, routeNotFoundResponse());
}
} catch (error) {
console.log(error);
return callback('ERROR: Get Route Failed.', internalErrorResponse());
}
};
Haider Abbas
01/25/2022, 9:29 PMJay
Haider Abbas
02/07/2022, 7:39 AM