@aashari/mcp-server-aws-sso
Version:
Node.js/TypeScript MCP server for AWS Single Sign-On (SSO). Enables AI systems (LLMs) with tools to initiate SSO login (device auth flow), list accounts/roles, and securely execute AWS CLI commands using temporary credentials. Streamlines AI interaction w
33 lines (32 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultAwsRegion = getDefaultAwsRegion;
const child_process_1 = require("child_process");
const logger_util_js_1 = require("./logger.util.js");
const logger = logger_util_js_1.Logger.forContext('utils/aws.sso.util.ts');
/**
* Gets the default AWS region from environment variables or AWS CLI configuration
* @returns The AWS region string
*/
function getDefaultAwsRegion() {
// First check environment variables (AWS SDKs check these first)
const envRegion = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
if (envRegion) {
return envRegion;
}
// If environment variables aren't set, try to get from AWS CLI config
try {
const cliRegion = (0, child_process_1.execSync)('aws configure get region', {
encoding: 'utf8',
}).trim();
if (cliRegion) {
return cliRegion;
}
}
catch (error) {
logger.debug('Failed to get region from AWS CLI config', error);
// Continue to fallback if AWS CLI command fails
}
// Fallback to a default region
return 'ap-southeast-1';
}