1

I m creating an object of KinesisClient class using AWS SDK 2.x in java like this

AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(
        AwsBasicCredentials.create("access-key",
            "secret-key")
    );
    KinesisClient kinesisClient  = KinesisClient.builder()
        .credentialsProvider(credentialsProvider)
        .build();

when I am executing this code, I am getting below exception

Exception in thread "main" java.lang.IllegalArgumentException: Expected a profile definition on line 1
    at software.amazon.awssdk.utils.Validate.isTrue(Validate.java:76)
    at software.amazon.awssdk.profiles.internal.ProfileFileReader.readPropertyDefinitionLine(ProfileFileReader.java:125)
    at software.amazon.awssdk.profiles.internal.ProfileFileReader.parseLine(ProfileFileReader.java:78)
    at software.amazon.awssdk.profiles.internal.ProfileFileReader.lambda$parseFile$0(ProfileFileReader.java:58)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
    at software.amazon.awssdk.profiles.internal.ProfileFileReader.parseFile(ProfileFileReader.java:58)
    at software.amazon.awssdk.profiles.ProfileFile$BuilderImpl.build(ProfileFile.java:265)
    at software.amazon.awssdk.profiles.ProfileFile.lambda$addCredentialsFile$0(ProfileFile.java:142)
    at java.util.Optional.ifPresent(Optional.java:159)
    at software.amazon.awssdk.profiles.ProfileFile.addCredentialsFile(ProfileFile.java:139)
    at software.amazon.awssdk.utils.builder.SdkBuilder.applyMutation(SdkBuilder.java:61)
    at software.amazon.awssdk.profiles.ProfileFile.defaultProfileFile(ProfileFile.java:90)
    at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.mergeGlobalDefaults(SdkDefaultClientBuilder.java:196)
    at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration(SdkDefaultClientBuilder.java:149)
    at software.amazon.awssdk.services.kinesis.DefaultKinesisClientBuilder.buildClient(DefaultKinesisClientBuilder.java:28)
    at software.amazon.awssdk.services.kinesis.DefaultKinesisClientBuilder.buildClient(DefaultKinesisClientBuilder.java:22)
    at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:124)

is there anything i m missing for that profile thing, or there is some other way to create the Client object. Thanks in advance!

2 Answers2

2

Invalid key-values/characters could cause that exception. Could you please check if you got any invalid characters or values in cat ~/.aws/credentials or cat ~/.aws/config files.

  • 1
    Instead of a speculative "maybe" as answer, combined with a question, please use your commenting privilege. Then create an assertive answer when things are clear and you have narrowed down OPs problem to the point that a definitive answer is possible. – Yunnosch Mar 15 '21 at 18:34
  • The phrasing may be poor but this actually solved my (similar) problem. – Erica Kane Oct 06 '21 at 19:06
0

In addition to the answer from Venkata, the format of the credentials file appears to be important and the error may not make this obvious.

For example, I found that this format does not work (Mac OS in ~/.aws/credentails):

[default] 
aws_access_key_id=AKIARQV2GJHGK78 aws_secret_access_key=Op+kW9cXLL9dddtSNRuRccULcL5gt4VUx6ywOObN

while this format does (i.e. on separate lines):

[default] 
aws_access_key_id=AKIARQV2GJHGK78
aws_secret_access_key=Op+kW9cXLL9dddtSNRuRccULcL5gt4VUx6ywOObN

(above are not real keys!)

More info here: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html

Mick
  • 24,231
  • 1
  • 54
  • 120