I'm migrating AWS SDK for java from v1 to v2. Earlier I was instantiating the AWSIotMqttClient
like
Credentials cred = awsService.generateTempIAMCredentialsForIOT();
// AWS IAM credentials could be retrieved from AWS Cognito, STS etc.
IOTMqttClient client = new IOTMqttClient(iotEndpoint, clientId, cred.accessKeyId(),
cred.secretAccessKey(), cred.sessionToken(), this);
the sdk-v2 doesn't seem to have any way to use IAM credentials for MqttClientConnection
or Mqtt5Client
.
Does anyone know a possible way to accomplish this via sdk-v2?
Thanks
AWS SDK in general has a good way for looking for configuration with minimal intervention / configuration from the developer, as long as you make sure you have the necessary configuration in place, either it's giving necessary IAM Policy access or having temporary credentials placed in a config file.
Please have a deep dive into
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html
Which basically suggests you don't need to specify anything if you assign the right policy to the resource you are running your code at.