amazon-kinesis-client-python: Problem trying to refresh assume-role credentials automatically with KCL on EC2
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 in kcl.properties to automatically refresh the temporary credentials.
The credentials in kcl.properties is as follows:
AWSCredentialsProvider = STSAssumeRoleSessionCredentialsProvider|arn:aws:iam::<account-id>:role/<role-name>|session-name
But I seem to be running into the following issue.
No credential providers specifiedjava com.amazonaws.services.kinesis.multilang.MultiLangDaemon <properties file>
I’m using the Amazon KCL Version : 1.4.4 with the following JARS:
- amazon-kinesis-client-1.7.5.jar
- aws-java-sdk-cloudwatch-1.11.115.jar
- aws-java-sdk-core-1.11.115.jar
- aws-java-sdk-dynamodb-1.11.115.jar
- aws-java-sdk-kinesis-1.11.115.jar
- aws-java-sdk-kms-1.11.115.jar
- aws-java-sdk-s3-1.11.115.jar
- commons-codec-1.9.jar
- commons-lang-2.6.jar
- commons-logging-1.1.3.jar
- guava-18.0.jar
- httpclient-4.5.2.jar
- httpcore-4.4.4.jar
- ion-java-1.0.2.jar
- jackson-annotations-2.6.0.jar
- jackson-core-2.6.6.jar
- jackson-databind-2.6.6.jar
- jackson-dataformat-cbor-2.6.6.jar
- jmespath-java-1.11.115.jar
- joda-time-2.8.1.jar
- protobuf-java-2.6.1.jar
Any help with respect to missing JARs or configuration specifics would be helpful.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 2
- Comments: 20 (3 by maintainers)
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:
CLASSPATH_PREFIX=./logback ./bin/multilang-daemon config/kcl.local.propertiesIt 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.
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:
pom.xmlmvn packagetarget/appassembler/bin/multilang-daemon, and all the jars are intarget/appassembler/repo.target/appassemblerto wherever you need it.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.
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
AWSCredentialsProvider. I’m curious to know where you found the format in the first place? I haven’t been able to find any kind of documentation for it.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
If this doesnt work, add sts-sdk manually using this command
wget https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-sts/1.12.428/aws-java-sdk-sts-1.12.428.jar -O "$APP_ROOT"/kcl/aws-sdk-sts.jarand append java path of the location
KCL_COMMAND="$(python "$APP_ROOT"/kcl/helper.py --print_command --java /usr/bin/java --properties "$APP_ROOT"/kcl/consumer.properties --classpath "$APP_ROOT"/kcl/*.jar)"Works perfectly 💯