const { fromIni } = require("@aws-sdk/credential-providers"); /** * Get AWS configuration based on environment * - Development: Uses AWS credential profiles from ~/.aws/credentials * - Production: Uses IAM roles (EC2/Lambda/ECS instance roles) */ function getAWSCredentials() { if (process.env.NODE_ENV === "dev") { // Local development: use profile from ~/.aws/credentials const profile = process.env.AWS_PROFILE; return fromIni({ profile }); } } /** * Get complete AWS client configuration */ function getAWSConfig() { const config = { region: process.env.AWS_REGION, }; const credentials = getAWSCredentials(); if (credentials) { config.credentials = credentials; } return config; } module.exports = { getAWSConfig, getAWSCredentials, };