-
Notifications
You must be signed in to change notification settings - Fork 226
Problem trying to refresh assume-role credentials automatically with KCL on EC2 #51
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
Comments
Hi - I'm also trying to assume a role and so far have been unable to. I get the same message as you if I use the same format for Edit: Found the source code: https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/config/AWSCredentialsProviderPropertyValueDecoder.java#L72 |
The STSAssumeRoleSessionCredentialsProvider isn't in the aws-java-sdk-core jar, so you would need to add the aws-java-sdk-sts jar to the class path. If you don't mind using Apache Maven this is a pom.xml that will create a launch script that will setup the class path for you. To create the launcher script:
|
@pfifer , after following your suggestion and building
output contains extra echo call to dump classpath before calling exec. |
@antgus here is an example https://github.com/awslabs/amazon-kinesis-client/blob/master/src/test/java/com/amazonaws/services/kinesis/clientlibrary/config/AWSCredentialsProviderPropertyValueDecoderTest.java#L63
but seems does not work |
it seems works with |
I've just tested it using the line below (with redactions), and was able to access a stream in another account:
I've tested this with version 1.11.151, and 1.11.129 of the STS SDK. To get more information I've updated the pom.xml to include some logging libraries. You can use this without a logging configuration file, but it will default to DEBUG. You can configure the logging using these steps:
It defaults to logging output to the console, but if you switch the logger to MAIN it will output to a file. This also enable debug logging, which can help us understand what is going on. |
I have a slightly different issue with this. I have the jars loaded and it's picking up the STS provider, but it can no longer find the env vars containing my long lived creds:
The DefaultAWSCredentialsProviderChain works in the same config. |
Oh, right, I jumped the gun. That's probably the highly obscure exception raised when the AssumeRole api call gets AccessDenied, which happened when I used the CLI with the same roles. |
So, once I fixed the trust relationship, all worked well. |
Hello @pfifer! I'm struggling with the same problem as jazzTheJackRabbit and ykhrustalev. I'm using python.
Do I understand it correctly that KCL does not read configuration from ~/.aws/config and it is useless to create profiles with (assume)roles there? This approach works for me with boto3 library on python. Any help will be highly appreciated. |
Found solution myself. For those experiencing the same problem and using python:
Of course, it would have been much better if the file was added to the library by default.
Previously, I didn't specify the session_name, cause boto3 didn't need it. That was a mistake. session_name can be anything, up to you. In my case I need different credentials for DynamoDB and for Kinesis. In this commit I found how to do it. |
Hello @pfifer! This thread has been really helpful to setup the Python KCL with STSAssumeRoleSessionCredentialsProvider. However, we enforce MFA to Assume Roles here. I am jumping in to know how I can configure this in the properties file. Is it even supported? Thanks, |
Hello @holmesjr . I have met the same error "Unable to load AWS credentials from any provider in the chain" Can I know how did u fix the trust relationship? Thanks |
Hello @pfifer ! then I export the AWS_PROFILE variable in the following way: As you mentioned above, STSAssumeRoleSessionCredentialsProvider isn't in the aws-java-sdk-core jar. So I manually downloaded aws-java-sdk-sts-1.11.300.jar and added it into the same directory where other jars stored. Then I changed AWSCredentialsProvider property into STSAssumeRoleSessionCredentialsProvider in property file. However, I always had this error "Unable to load AWS credentials from any provider in the chain" I have two questions:
|
The script uses a defined classpath so just adding the jar won't include it. I would recommend following the instructions in my earlier post. To answer your second question the STS jar is only required for those using the STS credentials. We don't want to increase the required dependencies unless absolutely necessary. |
Hello @pfifer, is there a way to pass external_Id when using STSAssumeRoleSessionCredentialsProvider? |
I have followed the same , however not sure why still getting this below error - any idea please Caused by: java.lang.IllegalArgumentException: No credential providers specified |
this worked for me after hours of errors |
If this doesnt work, add sts-sdk manually using this command and append java path of the location Works perfectly 💯 |
|
I have a Kinesis Stream Reader setup on an EC2 instance with the an instance profile with assume-role permissions to assume a reader-role to a Kinesis Stream in a separate AWS account. I can access the stream perfectly fine if I configure my credentials by using the STS service through the AWS-CLI, retrieve temporary credentials and setup the ~/.aws/credentials file accordingly. But, I'm running into problems if I try to use the
STSAssumeRoleSessionCredentialsProvider
inkcl.properties
to automatically refresh the temporary credentials.The credentials in
kcl.properties
is as follows:But I seem to be running into the following issue.
I'm using the
Amazon KCL Version : 1.4.4
with the following JARS:Any help with respect to missing JARs or configuration specifics would be helpful.
The text was updated successfully, but these errors were encountered: