Last active
September 17, 2025 11:01
-
-
Save filipeandre/aa39cf7dbfef4c4a8f5ad6cba00c93a4 to your computer and use it in GitHub Desktop.
Extract env variables from ecs task definition
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
| (() => { | |
| // 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