Created
February 10, 2023 18:10
-
-
Save garryyao/627601497854327b4baf84145b1e8050 to your computer and use it in GitHub Desktop.
Atlas Cluster Automation Scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = async function() { | |
// Supply projectID and clusterNames... | |
const projectID = '<your Atlas project id>'; | |
const clusterNames = ['<your cluster names>']; | |
// Get stored credentials... | |
console.log(context.values.get("AtlasPrivateKey")) | |
const username = context.values.get("AtlasPublicKey"); | |
const password = context.values.get("AtlasPrivateKey"); | |
// Set desired state... | |
const body = {paused: true}; | |
var result = ""; | |
clusterNames.forEach(async function (name) { | |
result = await context.functions.execute('modifyCluster', username, password, projectID, name, body); | |
console.log("Cluster " + name + ": " + EJSON.stringify(result)); | |
if (result.error) { | |
return result; | |
} | |
}) | |
return clusterNames.length + " clusters paused"; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = async function() { | |
// Supply projectID and clusterNames... | |
const projectID = '<your Atlas project id>'; | |
const clusterNames = ['<your cluster names>']; | |
// Get stored credentials... | |
const username = context.values.get("AtlasPublicKey"); | |
const password = context.values.get("AtlasPrivateKey"); | |
// Set desired state... | |
const body = {paused: false}; | |
var result = ""; | |
clusterNames.forEach(async function (name) { | |
result = await context.functions.execute('modifyCluster', username, password, projectID, name, body) | |
console.log("Cluster " + name + ": " + EJSON.stringify(result)); | |
if (result.error) { | |
return result; | |
} | |
}) | |
return clusterNames.length + " clusters resumed"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment