Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

awsmobile command does not work and hangs #157

Open
vu2sar opened this issue Jul 5, 2018 · 9 comments
Open

awsmobile command does not work and hangs #157

vu2sar opened this issue Jul 5, 2018 · 9 comments
Assignees

Comments

@vu2sar
Copy link

vu2sar commented Jul 5, 2018

Hi,

When using awsmobile configure/pull commands the command hangs up and does not execute. This is the same case for awsmobile init command as well

capture

The entire command hangs and i am forced to exit it with Ctrl + C. I am running windows 10 and the latest version of nodejs.

P.S This occurs only on the latest version of nodejs(10.4) when i used the LTS everything was fine.

@vu2sar vu2sar changed the title Any awsmobile command does not properly awsmobile command does not work and hangs Jul 5, 2018
@rqton
Copy link

rqton commented Jul 6, 2018

Same issue with same environment (Windows 10, NodeJS 10).
Downgrade on NodeJS 8.11.3 is a good workaround, thanks @vu2sar

@Bforsyth1234
Copy link

@rqton Is correct I had node 10 and downgraded to lts and it worked Thanks!

@carlfedak
Copy link

Downgrading is not a good workaround, that is ridiculous, there are many features we would be giving up to downgrade node. What is the latest status on this, it has been in investigation for over 1 month?

@Megajin
Copy link

Megajin commented Sep 9, 2018

After looking into the source code I am 100% positive that this issue is related to Inquirer.js in combination with NodeJS 10.x.x.

In file: lib\aws-operations\aws-config-manager.js

function setConfig(awsDetails, callback){
    if(!awsDetails){
        awsDetails = resolveAWSConfig(true)
    }
    
    let awsInfo = awsDetails.info
    let awsConfig = awsDetails.config

    inquirer.prompt([
        {
            type: 'input',
            name: 'accessKeyId',
            message: "accessKeyId: ",
            default: awsConfig.accessKeyId
        },
        {
            type: 'input',
            name: 'secretAccessKey',
            message: "secretAccessKey: ",
            default: awsConfig.secretAccessKey
        },
        {
            type: 'list',
            name: 'region',
            message: "region: ",
            choices: awsMobileRegions,
            default: awsConfig.region
        }
    ]).then(function (answers) {
        let awsConfigChanged = false
        if(answers.accessKeyId){
            let newKeyId = answers.accessKeyId.trim()
            if(awsConfig.accessKeyId != newKeyId){
                awsConfig.accessKeyId = newKeyId
                awsConfigChanged = true
            }
        }
        if(answers.secretAccessKey){
            let newKey = answers.secretAccessKey.trim()
            if( awsConfig.secretAccessKey != newKey){
                awsConfig.secretAccessKey = newKey
                awsConfigChanged = true
            }  
        }
        if(answers.region){
            let newRegion = answers.region.trim()
            if( awsConfig.region != newRegion){
                awsConfig.region = newRegion
                awsConfigChanged = true
            }  
        }
        if(awsConfigChanged){
            let jsonString = JSON.stringify(awsConfig)
            fs.writeFileSync(awsInfo.AWSConfigFilePath, jsonString, 'utf8')
            awsConfigInfoManager.setNoProfileSync(awsInfo)
        }

        if(callback){
            callback(awsDetails)
        }
    })
}

After the inquirer.prompt call, the next promise won't resolve itself. Hence it hangs up which is leading to invalid tokens.

@UnleashedMind

@tuf22191
Copy link

Hi, this is really frustrating. For a company as large as Amazon, this should not be a problem. Has anyone looked at Megajin's analysis and developed an alternative?

@UnleashedMind
Copy link
Contributor

UnleashedMind commented Sep 12, 2018

Sorry to hear your frustration.
But it seems like the only work around right now is to downgrade to node 8.9.x when running on Windows 10.
People reported similar issues on inquirer when running on Windows 10
SBoudrias/Inquirer.js#643
Shopify/slate-cli#87

@david-ghikas
Copy link

Had the same problem. The following command which bypasses the prompts worked for me:

awsmobile configure aws $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AWS_DEFAULT_REGION

@akash-saxena150
Copy link

Had the same problem. The following command which bypasses the prompts worked for me:

awsmobile configure aws $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AWS_DEFAULT_REGION

This worked for me as well. I'm running Node 10.15

@Lor3nzoMartinez
Copy link

I had the same problem and nothing was really working and I ended up using the git scm bash command line and running the command and was able to configure and init the whole thing hope that helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants