Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load aws credentials stored in ~/.aws/ using my own profile name #4341

Closed
Gujarats opened this issue Feb 13, 2018 · 6 comments
Closed

Load aws credentials stored in ~/.aws/ using my own profile name #4341

Gujarats opened this issue Feb 13, 2018 · 6 comments
Labels
a:feature A new functionality stale

Comments

@Gujarats
Copy link

Expected Behavior

I'm trying to load aws credentials from default config file ~/.aws/. using this code snippet :

    repositories {
        maven {
            url "${internal_s3_url}"
            authentication {
                awsIm(AwsImAuthentication)
            }
        }
    }

And here is my credential looks like :

[test-gujarat]
aws_access_key_id =~~
aws_secret_access_key =~~
[gujarat.santana]
aws_access_key_id =~~
aws_secret_access_key = ~~

I know if I changed the profile gujarat.santana to default it will load the access_key and secret_key. Now Is it possible not to use default profile and using my own name profile? if Possible, how do I do that ?

Current Behavior

Currently I got this error Unable to load AWS credentials from any provider in the chain after running gradle build.

Context

I need to use another profile name instead of using default profile since I have many access_key and secret_key in my local. The reason why I don't want to use default is because I would like to make my default profile for my admin user in my aws account and use another profile to for another access and permission.

Steps to Reproduce (for bugs)

If you have your S3 bucket in aws and IAM user in aws which has access_key and secret_key then put it in your ~/.aws/credentials. and load the profile name with your own name not default profile.

Your Environment

------------------------------------------------------------
Gradle 4.2.1
------------------------------------------------------------

Build time:   2017-10-02 15:36:21 UTC
Revision:     a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_151 (Oracle Corporation 25.151-b12)
OS:           Linux 4.4.0-109-generic amd64
@blindpirate
Copy link
Collaborator

Well, AFAIK the aws configuration file is read by AWS-SDK and there's no special setting on Gradle's side to specify a "user". Currently a workaround could be Environment variables/Java system properties (see here) or even parse the ~/.aws/credentials youself.

@Gujarats
Copy link
Author

Gujarats commented Feb 14, 2018

Okay I see now, thanks for the info. I would to see this new feature can be easily called like for example

repositories {
        maven {
            url "${internal_s3_url}"
            authentication {
                awsIm(YOUR_PROFILE_NAME)
            }
        }
    }

Or maybe you have another suggestion since I don't really like to see the previous one like awsIm(AwsImAuthentication) because I don't see it really matter to call the AwsImAuthentication inside awsIm(). But still it is a suggestion from me.

And about what you said configuration file is read by AWS-SDK Is it possible if their SDK is not currently supported to call specify a "user" ?

@ngortheone
Copy link

Any updates on this? Very interested in described functionality.

@pebberio
Copy link

One solution is to set the AWS_PROFILE environment variable as described in the docs at https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

export AWS_PROFILE=test-gujarat
./gradlew build

or inline
AWS_PROFILE=test-gujarat ./gradlew build

or as an alias in ~/.bashrc or similar, where you can also add some logic based on a config file
alias gw='AWS_PROFILE=test-gujarat ./gradlew'

@stale
Copy link

stale bot commented Aug 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Aug 5, 2020
@stale
Copy link

stale bot commented Aug 26, 2020

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Aug 26, 2020
@wolfs wolfs closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality stale
Projects
None yet
Development

No branches or pull requests

5 participants