Home > Software engineering >  Get IAM Role information programatically using Scala
Get IAM Role information programatically using Scala

Time:12-09

I want to receive the role information for a role name. For example getting the exact ARN identifier.

Somehow this code below is not working. Sadly there is no error message in cloudwatch

import software.amazon.awssdk.services.iam.*;

import com.amazonaws.services.identitymanagement.model._
import com.amazonaws.services.identitymanagement.{AmazonIdentityManagementClient, AmazonIdentityManagement, AmazonIdentityManagementClientBuilder}
// ....

val iamClient = AmazonIdentityManagementClient
    .builder()
    .withRegion("eu-central-1")
    .build()

val roleRequest = new GetRoleRequest();
roleRequest.setRoleName("InfrastructureStack-StandardRoleD-HBLE12VPTWQ")

val result = iamClient.getRole(roleRequest) // <-- Nothing happens after this line
println("wont execute this println statement")

Other services like CognitoIdentityProvider are working perfectly fine.

I also tried the builder pattern for the GetRoleRequest and IamClient.

CodePudding user response:

I got this IAM V2 code working fine. As stated in my comment, setup your dev environment to use enter image description here

  • Related