Hello,
I made a function to use in APP Services, where they run Scale UP and Scale Down instances in the mongodb cluster, but when Triggers fire and execute the function, for example:
M60 (Low-CPU) it migrates to the M50 it stays as General does not maintain the (Low-CPU).
I tried to find something in this documentation but I couldn’t find it:
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Multi-Cloud-Clusters/operation/updateCluster
My Function is this:
exports = async function() {
// Forneça projectID e clusterNames...
const projectID = 'XXXXXXXXXXXXXXXXXXXXX';
const clusterName = 'cloud-prod';
// Obter credenciais armazenadas...
const username = context.values.get("AtlasPublicKey");
const password = context.values.get("AtlasPrivadeKeySecret");
// Defina o tamanho de instância desejado...
const body = {
"providerSettings" : {
"providerName" : "AWS",
"instanceSizeName" : "M50"
}
};
result = await context.functions.execute('modifyCluster', username, password, projectID, clusterName, body);
console.log(EJSON.stringify(result));
if (result.error) {
return result;
}
return clusterName + " scaled down";
};