CloudStorageMaven icon indicating copy to clipboard operation
CloudStorageMaven copied to clipboard

AWS: Assume Roles

Open stourwalk-work opened this issue 5 years ago • 3 comments

I'm trying to use the s3-storage-wagon with ARN profile support as mandated by my corporate environment and am struggling to get it to work via mvn.

All the credentials are configured and I can do a aws s3 ls mybucket or aws s3 cp file.txt mybucket and it works perfectly, but I consistently get "Unable to find a region via the region provider chain. " from maven.

I have AWS_PROFILE, AWS_DEFAULT_REGION and the other AWS key variables set in my bash profile and .aws/credentials. The is also set in the section of s3-upload

That I have to use a profile is the only reason I can think that the upload is failing

stourwalk-work avatar Sep 19 '19 14:09 stourwalk-work

Please try to do

AWS_DEFAULT_REGION=your-region AWS_ACCESS_KEY_ID=access_key AWS_SECRET_ACCESS_KEY=secret_key mvn clean deploy

or through your settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0                         https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>repo-id</id>
      <username>access_key</username>
      <password>secret_key</password>
      <configuration>
        <region>eu-west-2</region>
      </configuration>
    </server>
  </servers>
</settings>

gkatzioura avatar Sep 20 '19 10:09 gkatzioura

I have those entries in my settings.xml and also in my environment. Maven is normally run through eclipse (and I've also added the Environment Vars to the Environment section of the Run Configuration as well) I've also got AWS_PROFILE={profilename} and the corresponding [profilename] section in my .aws/credentials file

From the command line I still get [ERROR] Failed to execute goal com.gkatzioura.maven.cloud:s3-storage-wagon:2.1:s3-upload (upload-jar) on project RaaS: Execution upload-jar of goal com.gkatzioura.maven.cloud:s3-storage-wagon:2.1:s3-upload failed: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region. -> [Help 1]

credentials `[default] aws_access_key_id=access_key aws_secret_access_key=secret region=us-east-1 output=json

[raas2prod] role_arn=arn:aws:iam::nnnnnnnn:role/managed-role/rolename source_profile=default`

stourwalk-work avatar Sep 20 '19 15:09 stourwalk-work

@stourwalk-work you might need to provide the region in raas2prod profile in your ~/.aws/credentials file.

pjroth avatar Feb 13 '20 21:02 pjroth