I have problem initializing API Gateway Client in Java using AWS-Java-SDK (tried old and newest version). I’ve checked 10 times if my access and secret keys are correct and they are. I’m not sure what i bad coded so it stops working after "Good 2" output. Need help please
Here’s my code:
public void startAPIGateway() {
callbacks.printOutput("Starting API Gateway");
String API_NAME = "Testing";
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKeyField.getText(), secretKeyField.getText());
callbacks.printOutput("Good 1");
// Create an AWSStaticCredentialsProvider object with the credentials
AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
callbacks.printOutput("Good 2");
// Create an AwsClientBuilder object with the region and endpoint;
AmazonApiGatewayClientBuilder clientBuilder = AmazonApiGatewayClientBuilder.standard().withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://apigateway.eu-east-2.amazonaws.com", "eu-east-2"));
callbacks.printOutput("Good 3");
// Set the credentials provider on the client builder
clientBuilder.setCredentials(credentialsProvider);
clientBuilder.setRegion("eu-east-2");
AmazonApiGateway client = clientBuilder.build();
callbacks.printOutput("Goodzzzz");
CreateRestApiRequest restApiRequest = new CreateRestApiRequest().withName(API_NAME);
CreateRestApiResult createRestApiResult = client.createRestApi(restApiRequest);
callbacks.printOutput(createRestApiResult.getId());
// Add a new resource with a path variable
GetResourcesRequest getResourcesRequest = new GetResourcesRequest()
.withRestApiId(createRestApiResult.getId());
GetResourcesResult getResourcesResult = client.getResources(getResourcesRequest);
CreateResourceRequest createResourceRequest = new CreateResourceRequest()
.withRestApiId(createRestApiResult.getId())
.withParentId(getResourcesResult.getItems().get(0).getId())
.withPathPart("{proxy+}");
CreateResourceResult createResourceResult = client.createResource(createResourceRequest);
}
2
Answers
Installed AWS SDK for Java 2 by Maven and added this code, still my extension for Burp is not working:
Resulted with this:
You are using the old Java V1 API. This is no longer recommended to use by the AWS SDK Java team. You should consider moving to AWS SDK for Java V2. You can read about this SDK version here:
Developer guide – AWS SDK for Java 2.x
To get this service working with V2, setup your credentials in the .aws folder as described in the DEV Guide here:
See this topic:
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html
No need to specify your creds in your code. Once you set the creds according to the docs, you can successfully use an ApiGatewayClient.
This code example demonstrates how to obtain information about the current ApiKeys.
The following screen shot shows this code working and the output.