In your package.json
a script can point to a javascript file. The file in turn could contain a more robust script.
"scripts": {
"createEndpoint": "node ./myscript.js"
}
To do it all in one command/script you might want to look at how to process arguments this question/answer talks about how it works https://stackoverflow.com/a/14404223/10555693. Additionally, NodeJS docs for argv NodeJS: process.argv
The more robust script could make use of the JS AWS SDK, take in arguments, and create the resource, method, and deployment.
Some specific method references you might find useful:
Example (Just a start):
const AWS = require('aws-sdk');
async function createEndPoint() {
const apiGateway = new AWS.APIGateway();
const resourceParams = {
parentId: '',
pathPart: '',
restApiId: '',
};
const newResource = await apiGateway.createResource(resourceParams).promise();
const methodParams = {
resourceId: newResource.id,
. /* other params */
.
.
};
const newMethod = await apiGateway.putMethod(methodParams);
}
createEndPoint();