diff --git a/bin/scotty.js b/bin/scotty.js index 08988ac..2242d02 100755 --- a/bin/scotty.js +++ b/bin/scotty.js @@ -135,11 +135,11 @@ function cmd(console) { if (!AWS.config.credentials) return console.log(`Set AWS credentials first. Guide is available here: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html`) - if (!AWS.config.region) + if (!args.region) { return getDefaultRegion() .catch(() => { if (args.force) - return saveDefaultRegion(args.region || 'us-east-1') + return 'us-east-1' return inquirer.prompt([{ type: 'list', @@ -152,8 +152,10 @@ function cmd(console) { .then(saveDefaultRegion) }) .then(region => beamUp(args, region, console)) + } - return beamUp(args, AWS.config.region, console) + return saveDefaultRegion(args.region) + .then(() => beamUp(args, args.region, console)) } function beamUp (args, region, console) { diff --git a/lib/scotty.js b/lib/scotty.js index f3c142a..06b9673 100644 --- a/lib/scotty.js +++ b/lib/scotty.js @@ -34,6 +34,8 @@ function createOrUpdateBucket(bucket, region, update, force, quiet, logger) { if (err.code === 'BucketAlreadyExists') err.message += '\n\nTry running the command with a new bucket name: \n scotty --bucket some-new-unique-name\n\nor change the name of your folder and re-run the same command.' + if (err.code === 'InvalidLocationConstraint') + err.message += '\n\nBucket already exists in a different region. Please change to: \n a) the correct region (using `-r region-name`) \n OR \n b) a different bucket name (using `-b bucket-name`)' throw err }) }