Last active
June 20, 2025 19:31
-
-
Save DavidWells/394de3fb3bcf7e3fc09148f4303d814f to your computer and use it in GitHub Desktop.
Open AWS resource console via Arn via https://twitter.com/matthewdfuller/status/1936076217167339588
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
#!/usr/bin/env node | |
const { exec } = require('child_process') | |
const { platform } = require('os') | |
// Get ARN from command line arguments | |
const arn = process.argv[2] | |
if (!arn) { | |
console.error('Usage: node aws-open-link.js <resource-arn>') | |
console.error('Example: node aws-open-link.js arn:aws:s3:::my-bucket') | |
process.exit(1) | |
} | |
// Construct the AWS console URL | |
const awsConsoleUrl = `https://console.aws.amazon.com/go/view?arn=${encodeURIComponent(arn)}` | |
console.log('Opening AWS Console link:') | |
console.log(awsConsoleUrl) | |
// Determine the appropriate Chrome command based on the platform | |
let chromeCommand | |
switch (platform()) { | |
case 'darwin': // macOS | |
chromeCommand = 'open -a "Google Chrome"' | |
break | |
case 'win32': // Windows | |
chromeCommand = 'start chrome' | |
break | |
default: // Linux and others | |
chromeCommand = 'google-chrome' | |
break | |
} | |
// Execute the command to open Chrome with the URL | |
exec(`${chromeCommand} "${awsConsoleUrl}"`, (error, stdout, stderr) => { | |
if (error) { | |
console.error('Error opening Chrome:', error.message) | |
console.log('Please manually open this URL in your browser:') | |
console.log(awsConsoleUrl) | |
process.exit(1) | |
} | |
if (stderr) { | |
console.error('Chrome stderr:', stderr) | |
} | |
console.log('AWS Console opened successfully in Chrome!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment