Search code examples
amazon-web-servicesaws-sdkaws-api-gatewayaws-java-sdk

How do you make a Java client side call to an AWS API gateway, that has an IAM role accosiated to it


I am looking for examples of the java code used to make a call to an AWS API Gateway.

I can make the call to an AWS API gateway that dose not require IAM verification but I am finding it very difficult to find a clear example of how to structure a URL.

How do you pass in the Secret key and Secret Key ID appropriately? Do I have to complete all the steps required to encode the URL in accordance with Signature Version 4 protocol or can I just include the key and key ID with the URL?

Is there a code example of a client side program, written in Java, that uses the AWS SDK to make a call to an AWS API Gateway? As in a generic call in which you can pass in the URL and other parameters as they are required?

I have tried to use the AWS Java SDK that is generated by the AWS API Gateway. I am having trouble using the generated SDK any tutorials would be greatly appreciated. I can't find documentation on how to use the constructed SDK to make a call to the API. I have used MAVEN to build the SDK.. I think, I was trying to follow this tutorial...

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-apigateway-generated-java-sdk.html

.... but I am unsure if I have installed the SDK correctly and I can't see where the secret key and key ID are passed in to the API call...


Solution

  • You should be able to initial the SDK client with credential and pass in a credential provider, like,

    BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id");
    SimpleCalcSdk sdkClient = SimpleCalcSdk.builder()
                             .withCredentials(awsCreds)
                             .build();