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>
The equivalent would be
AWSGlueClient.builder().withRegion("us-east-1").build()
Most AWS Java SDK client 'builders' follow the below convention:
ServiceName serviceName = ServiceName ClientBuilder.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();
If your lambda is in the same region as Glue resources then simply use
AWSGlue glueClient = AWSGlueClientBuilder.defaultClient()
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.