Hi folks,
Has anyone here gotten the AWS SDK working with gradle and Gatling? I’m trying to use Secrets Manager to store credentials, which I’ll then pull down and use to hit an oAuth endpoint. I’m using the Gatling plugin for gradle, and I’ve followed the directions here, but I end up getting errors like “object amazonaws is not a member of package com” when I run the :gatlingRun task.
If I run “gatling -q dependencies” to look at which modules gradle thinks it can hit, I get both
testCompileClasspath - Compile classpath for source set ‘test’.
±-- software.amazon.awssdk:bom:2.5.29
±-- software.amazon.awssdk:secretsmanager:2.5.29 (c)
±-- software.amazon.awssdk:aws-json-protocol:2.5.29 (c)
±-- software.amazon.awssdk:protocol-core:2.5.29 (c)
±-- software.amazon.awssdk:sdk-core:2.5.29 (c)
±-- software.amazon.awssdk:auth:2.5.29 (c)
±-- software.amazon.awssdk:http-client-spi:2.5.29 (c)
, which seems to suggest that it sees the Secrets Manager module just fine, but also
incrementalScalaAnalysisFormain - Incremental compilation analysis files for main
±-- software.amazon.awssdk:bom:2.5.29 → 2.5.29 FAILED
-– software.amazon.awssdk:secretsmanager FAILED
incrementalScalaAnalysisFortest - Incremental compilation analysis files for test
±-- software.amazon.awssdk:bom:2.5.29 → 2.5.29 FAILED
I think you’re confusing AWS SDK v1 and v2.
You’re pulling AWS SDK v2 but the compiler error suggests you’re coding against SDK v1.
Thanks, Stéphane; that’s really interesting. How would I code against v2? All the code says, in relevant part, is
import com.amazonaws.services.secretsmanager._
which just seemed like the appropriate import to pair with this, from build.gradle:
dependencies {
implementation platform(‘software.amazon.awssdk:bom:2.5.29’)
implementation ‘software.amazon.awssdk:secretsmanager’
}
Is there something I should be using instead?
Many thanks,
Steve
Sorry, I can’t really help with your custom code.
All I can tell is that the package of the AWS SDK classes has changed from com.amazonaws to software.amazon in AWS SDK v2.
Yeah, sorry, I realized that I had emailed the wrong thing: in an earlier iteration, I’d used ‘import com.amazonaws…’. If I change that to ‘import software.amazon.awssdk’, I get “not found: object software”.
So a slightly different problem even if I’m using v2 everywhere.
Sorry for my mistake,
Steve
It looks like your AWS SDK libraries are not in the classpath.
Sorry, can’t help with that as you use gradle: not familiar and this gradle plugin for Gatling is a third-party, not an official component.
No worries. Thanks for your help, Stéphane.
Quick followup, for those who are curious: the problem turned out to be that the gatling plugin to gradle introduces a “configuration”, which is a concept that’s new to me; it seems to override existing keywords with its own. So whereas the AWS docs relating to gradle and the SDK say to use, in relevant part,
dependencies { implementation platform(‘software.amazon.awssdk:bom:2.5.29’) implementation ‘software.amazon.awssdk:kinesis’
, it turns out that the gatling plugin overrides this: ‘implementation’ needs to become ‘gatling’.
With that fix made, everything else works.
Hopefully this will be useful to other people Googling later for the AWS SDK, gradle, and Gatling. I intend to write up a blog post or something for that purpose.
Take care,
Steve