简体   繁体   中英

Maven Unable to load AWS credentials from any provider in the chain

I am trying to pull down a maven project that uses AWS. I have an aws IAM user with a key and password. I ran aws configure and configured the ~/.aws/credentials file in the default account. However, when I run maven clean install, I get the following error:

Failed to execute goal on project project-name: 
Could not resolve dependencies for project com.project:project-name:war:1.0: 
Failed to collect dependencies at com.project:commons-java:jar:1.0.0: 
Failed to read artifact descriptor for com.project:commons-java:jar:1.0.0: 
Could not transfer artifact com.project:commons-java:pom:1.0.0 
from/to project-maven-repo-releases (s3://project-maven-repo/releases): 
Unable to load AWS credentials from any provider in the chain

Clearly, maven cannot load the dependancies from s3. I have confirmed that my IAM user has s3 permissions. And, even though s3 is "regionless", I have supplied the correct region to the IAM account. I also have tried exporting the AWS variables to no avail. Any idea what could be the problem?

Thanks!

I was struggling with what appears to be the same issue for a while. After checking my permissions in AWS and going through a variety of other troubleshooting steps, I think my issue was resolved through changing the directory permissions for a number of different files in the build path and repo that I was trying to build. I had inadvertently cloned them and copied them over as "root", such that, even with sudo permissions, maven was failing to read my Amazon credentials.

Another step you can take to narrow down the issue is to determine where the fault lies. I accomplished this by downloading the AWS python sample , which will attempt to create and add to a bucket in your s3. If this works, that means that the problem is with maven, and your credentials can be accessed by other applications just fine, and that you have the correct permissions as far as s3 is concerned. If the python sample also doesn't work, it is easier to get into and debug where exactly the issue is (in my opinion).

If mvn doesn't pick the aws credentials from ~/.aws/credentials, then it can be explicitly set in.m2/settings.xml. Worked for me on fedora.


    <settings>
        <servers>
            <server>
                <id>maven-repository2</id>
                <username><AWS_ACCESS_ID></username>
                <password><AWS_SECRET_ACCESS_KEY></password>
            </server>
        </servers>
    </settings>

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