Last active
November 17, 2021 12:51
-
-
Save c0nscience/a78e5b96c13f4337a7e1b1ab63626a4b to your computer and use it in GitHub Desktop.
This script runs only on the aws console and replaces the account idea at the top with something more meaningful. If you are working in a multi-account environment this might come in handy.
This file contains 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
// ==UserScript== | |
// @name Human AWS Environment | |
// @namespace http://noidea.com/ | |
// @version 1 | |
// @description Replaces the account id with a human readable label. | |
// @author Benjamin Herzig | |
// @icon64 https://a0.awsstatic.com/libra-css/images/site/touch-icon-ipad-144-smile.png | |
// @grant none | |
// @include /^https:\/\/.*console.aws.amazon.com.*$/ | |
// @run-at document-end | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const envs = { | |
'accountid1': { | |
name: 'DEVELOPMENT', | |
bgColor: 'blue', | |
color: 'white', | |
}, | |
'accountid2': { | |
name: 'ACCEPTANCE', | |
bgColor: 'yellow', | |
color: 'black', | |
}, | |
'accountid3': { | |
name: 'PRODUCTION', | |
bgColor: 'red', | |
color: 'white', | |
}, | |
}; | |
const userMenu = document.getElementById('nav-usernameMenu'); | |
const label = userMenu.querySelector('span[title*="@"]') | |
let textContent = label.textContent; | |
let orgAccountId = textContent.split('@')[1].trim(); | |
const accountId = orgAccountId.replaceAll('-','') | |
let env = envs[accountId]; | |
label.textContent = textContent.replaceAll(orgAccountId, `${env.name} (${orgAccountId})`) | |
label.setAttribute('style', `background:${env.bgColor};color:${env.color};padding: 2px 4px;`) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment