1

I am trying to use Glue schema registry service in AWS with scala (or java should be useful also) and I tested two ways to assume a role but it results in an error:

"Unable to load credentials from any of the providers in the chain AwsCredentialsProviderChain(credentialsProviders=[SystemPropertyCredentialsProvider(), EnvironmentVariableCredentialsProvider(), WebIdentityTokenCredentialsProvider(), ProfileCredentialsProvider(), ContainerCredentialsProvider(), InstanceProfileCredentialsProvider()])"

I don't want to use environment variables so I tried STS to assume a role with the following code:

val assumeRoleRequest                = AssumeRoleRequest.builder.roleSessionName(UUID.randomUUID.toString).roleArn("roleArn").build
val stsClient                        = StsClient.builder.region(Region.EU_CENTRAL_1).build
val stsAssumeRoleCredentialsProvider = StsAssumeRoleCredentialsProvider.builder.stsClient(stsClient).refreshRequest(assumeRoleRequest).build

val glueClient = GlueClient
  .builder()
  .region(Region.EU_CENTRAL_1)
  .credentialsProvider(stsAssumeRoleCredentialsProvider)

Based on https://stackoverflow.com/a/62930761/17221117

The second way I used is using the following AWS code official documentation

But it fails also... I don't understand if this generate a token that I should use or just executing this code should work.

Anyone can help me with this?

P3gg
  • 23
  • 4
  • You need credentials to assume an IAM role. How are you supplying credentials to your app? – jarmod Jan 11 '22 at 21:49
  • Ahhh... ok, so I should add the credentials to GlueClient and then assume the role? In this moment I am assuming role before including credentials. – P3gg Jan 13 '22 at 08:40
  • 1
    Typically, when using an AWS compute service, you supply/configure an IAM role and the compute executes with credentials associated with that IAM role (Glue example [here](https://docs.aws.amazon.com/glue/latest/dg/create-an-iam-role.html)). – jarmod Jan 13 '22 at 12:14

0 Answers0