简体   繁体   中英

AWS opsworks createApp api won't work with provided password and username with bitbucket

I am trying to use aws node.js sdk inorder to create an app in OPSWorks.

My repository is at bitbucket and it is private.

I want to use the AWS api with my account password instead of SSH.

This is the code:

  var appParams = {
        Name: 'Demo app',
        StackId: userData.Stacks.stackId,
        Type: 'nodejs',
        AppSource: {
            Password: '*******',
            Type: 'git',
            Url: 'https://myUserName@bitbucket.org/myUserName/demofresh.git',
            Username: 'myUserName'
        }
    }
    opsworks.createApp(appParams, function(err, data) {
        if (err)
            callback(err);
        else{
            console.log(data);
            callback(data);
        }
    });

For some reason i am getting this error all the time when running an instance with this app.

Error:

---- Begin output of git ls-remote https://myUserName@bitbucket.org/myUserName/demofresh.git HEAD ----
STDOUT: 
STDERR: fatal: could not read Password for 'https://myUserName@bitbucket.org': No such device or address
---- End output of git ls-remote https://myUserName@bitbucket.org/myUserName/demofresh.git HEAD ----
Ran git ls-remote https://myUserName@bitbucket.org/myUserName/demofresh.git HEAD returned 128

I have also tried to change the url to:

Url: 'https://myUserName@bitbucket.org/myUserName/demofresh.git',

But then i got an error that it doesn't have a username field.

Some how it is not reading the password i have provided.

I have used DescribeApps with success just to make sure that the password and username were saved in the application at amazon servers.

So maybe there is a problem in the AWS API?

I just ran into the same issue and believe that I found the resolution by RTFM at AWS OpsWorks: http://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html

In that doc, it talks about setting up a private repo, and specifying a different repo connection string:

Private repository–Use the SSH read/write format shown in these examples:

  • Github repositories: git@github.com:project/repository.
  • Repositories on a Git server: user@server:project/repository

So, I went into bitbucket, copied my SSH Connection string and set it up like this:

git@bitbucket.org:repo_owner/project.git

Additionally, the document indicates two additional settings for git repos:

Selecting Git under Source Control displays two additional optional settings:

Repository SSH key

You must specify a deploy SSH key to access private Git repositories. For Git submodules, the specified key must have access to those submodules. For more information, see Using Repository SSH Keys.

Important

The deploy SSH key cannot require a password; AWS OpsWorks has no way to pass it through. Branch/Revision If the repository has multiple branches, AWS OpsWorks downloads the master branch by default. To specify a particular branch, enter the branch name, SHA1 hash, or tag name. To specify a particular commit, enter the full 40-hexdigit commit id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM