Skip to content

Instantly share code, notes, and snippets.

@filipeandre
Last active September 17, 2025 11:01
Show Gist options
  • Save filipeandre/aa39cf7dbfef4c4a8f5ad6cba00c93a4 to your computer and use it in GitHub Desktop.
Save filipeandre/aa39cf7dbfef4c4a8f5ad6cba00c93a4 to your computer and use it in GitHub Desktop.
Extract env variables from ecs task definition
(() => {
// Find the env vars table body via CSS attribute selectors
const tbody = document.querySelector(
'[id^="awsui-tabs-"][id$="-envVariables-panel"] table tbody'
);
if (!tbody) return "";
const rows = Array.from(tbody.querySelectorAll("tr"));
const exports = rows.map(tr => {
const cells = tr.querySelectorAll("td, th");
const key = (cells[0]?.textContent || "")
.trim()
.toUpperCase()
.replace(/\s+/g, "_"); // safer for bash
const valueRaw = (cells[2]?.textContent || "").trim();
const value = valueRaw.replace(/"/g, '\\"'); // escape quotes
return key ? `export ${key}="${value}"` : null;
}).filter(Boolean);
const bashScript = exports.join("\n");
console.log(bashScript);
return bashScript;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment