User guide

2. Put the code that you want to run in a .java file, and save the file in the src folder. To illustrate the
process, we use the code from Managing Cluster Security Groups Using the AWS SDK for Java (p. 52)
so that the file in the src directory is CreateAndModifyClusterSecurityGroup.java.
3. Compile the code.
javac -cp sdk/lib/aws-java-sdk-1.3.18.jar -d bin src\CreateAndModifyCluster
SecurityGroup.java
If you are using a different version of the AWS SDK for Java, adjust the classpath (-cp) for your version.
4. Run the code. In the following command, line breaks are added for readability.
java -cp "bin;
sdk/lib/*;
sdk/third-party/commons-logging-1.1.1/*;
sdk/third-party/httpcomponents-client-4.1.1/*;
sdk/third-party/jackson-core-1.8/*"
CreateAndModifyClusterSecurityGroup
Change the class path separator as needed for your operating system. For example, for Windows, the
separator is ";" (as shown), and for Unix, it is ":". Other code examples may require more libraries than
are shown in this example, or the version of the AWS SDK you are working with may have different
third-party folder names. For these cases, adjust the classpath (-cp) as appropriate.
To run samples in this document, use a version of the AWS SDK that supports Amazon Redshift.To
get the latest version of the AWS SDK for Java, go to AWS SDK for Java.
Setting the Endpoint
By default, the AWS SDK for Java uses the endpoint https://redshift.us-east-1.amazonaws.com/.
You can set the endpoint explicitly with the client.setEndpoint method as shown in the following
Java code snippet.
client = new AmazonRedshiftClient(credentials);
client.setEndpoint("https://redshift.us-east-1.amazonaws.com/");
For a list of supported AWS regions where you can provision a cluster, go to the Regions and Endpoints
section in the Amazon Web Services Glossary.
Signing an HTTP Request
Topics
Example Signature Calculation (p. 132)
Amazon Redshift requires that every request you send to the management API be authenticated with a
signature.This topic explains how to sign your requests.
If you are using one of the AWS Software Development Kits (SDKs) or the AWS Command Line Interface,
request signing is handled automatically, and you can skip this section. For more information about using
AWS SDKs, see Using the Amazon Redshift Management Interfaces (p. 128). For more information about
using the Amazon Redshift Command Line Interface, go to Amazon Redshift Command Line Reference.
To sign a request, you calculate a digital signature by using a cryptographic hash function. A cryptographic
hash is a function that returns a unique hash value that is based on the input. The input to the hash
API Version 2012-12-01
131
Amazon Redshift Management Guide
Signing an HTTP Request