Created
November 18, 2022 05:49
-
-
Save joshuaquek/18a3c0b42da28f750c36a1283ae4bccc to your computer and use it in GitHub Desktop.
Revisions
-
joshuaquek revised this gist
Nov 18, 2022 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -39,4 +39,5 @@ async function deleteSearchAndStreamDeployments () { } } deleteSearchAndStreamDeployments() -
joshuaquek created this gist
Nov 18, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Description: Deletes all deployment in case the CTQ bash script somehow fails 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ // Run this on NodeJS const axios = require('axios') async function deleteSearchAndStreamDeployments () { const API_KEY = 'YOUR ELASTIC CLOUD API KEY GOES HERE' let deployments = [] try { // Get all deployments from the Elastic Cloud Account const response = await axios({ method: 'GET', url: 'https://api.elastic-cloud.com/api/v1/deployments', headers: { Authorization: `ApiKey ${API_KEY}` }, data: {} }) deployments = response.data.deployments console.log('>>> deployments', deployments) } catch (error) { console.log(error.data) } for (const deployment of deployments) { if (deployment.name.includes('capture-the-query')) { const deploymentId = deployment.id try { // Wipe all deployments with "capture-the-query" in the name const response = await axios({ method: 'POST', url: `https://api.elastic-cloud.com/api/v1/deployments/${deploymentId}/_shutdown`, headers: { Authorization: `ApiKey ${API_KEY}` }, data: {} }) console.log('>>> Response: ', response.data) } catch (error) { console.log(error.data) } // Done, script will exit } } } deleteSearchAndStreamDeployments()