Dev Utkarsh
Dev Utkarsh

Reputation: 1496

How to Get AWS Glue Client in Java

I am trying to invoke a Job in AWS Glue from my Lambda code written in Java. But I am not able to get the Glue Client.

Like we have DynamoClient like this -

AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withRegion("us-east-1").build();

What would be the equivalent for Glue Client ?

AWSGlueClient glue = null; // how to instantiate client
StartJobRunRequest jobRunRequest = new StartJobRunRequest();
jobRunRequest.setJobName("TestJob");
StartJobRunResult jobRunResult = glue.startJobRun(jobRunRequest);

I am not seeing the AmazonGlueClientBuilder class. As I am new to glue, please let me know if I am doing it wrong or it there any other way I can use to invoke the glue job.

Also I am using the following Maven Dependency -

<dependency>            
   <groupId>com.amazonaws</groupId>
   <artifactId>aws-java-sdk-glue</artifactId>
   <version>1.11.289</version>
</dependency>

Upvotes: 2

Views: 5496

Answers (4)

Sharhabeel Hamdan
Sharhabeel Hamdan

Reputation: 1549

AWS Glue Client initalization and sample use in Java:

    AWSGlue glueClient = AWSGlueClient.builder().withRegion("us-east-1").build();
    StartJobRunRequest job = new StartJobRunRequest();
    job.setJobName("ETLJob");
    StartJobRunResult jobResult = glueClient.startJobRun(job);

Upvotes: 0

Yuriy Bondaruk
Yuriy Bondaruk

Reputation: 4750

If your lambda is in the same region as Glue resources then simply use

AWSGlue glueClient = AWSGlueClientBuilder.defaultClient()

Upvotes: 1

ravenblizzard
ravenblizzard

Reputation: 386

Most AWS Java SDK client 'builders' follow the below convention:

ServiceName serviceName = ServiceNameClientBuilder.standard()/default()...

There is one Glue 'instance' available per-account, per-region so something along the following lines should get you up and running.

AWSGlue awsGlueClient =
    AWSGlueClientBuilder.standard().withRegion(Regions.US_EAST_1).build();

Upvotes: 0

Hristo Vrigazov
Hristo Vrigazov

Reputation: 1407

The equivalent would be

AWSGlueClient.builder().withRegion("us-east-1").build()

Upvotes: 2

Related Questions