Associating a Security Group with a Cluster
Each cluster you provision has one or more security groups associated with it. You can associate a
security group with a cluster when you create the cluster, or you can associate a security group later by
modifying the cluster. For more information, see
To create a cluster (p. 8)
and
To modify a cluster (p. 13)
.
Managing Security Groups Using AWS SDK for
Java
The following example demonstrates common operations on security groups, including:
• Creating a new security group
• Adding ingress rules to a security group
• Associating a security group with a cluster by modifying the cluster configuration.
By default, when a new security group is created, it has no ingress rules. This example modifies a new
security group by adding two ingress rules. One ingress rule is added by specifying a CIDR/IP range; the
other is added by specifying an owner ID and Amazon EC2 security group combination.
For step-by-step instructions to run the following example, see
Running Java Examples for Amazon
Redshift Using Eclipse (p. 118)
. You need to update the code and provide a cluster identifier and AWS
account number.
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.redshift.AmazonRedshiftClient;
import com.amazonaws.services.redshift.model.*;
public class CreateAndModifyClusterSecurityGroup {
public static AmazonRedshiftClient client;
public static String clusterSecurityGroupName = "securitygroup1";
public static String clusterIdentifier = "***provide cluster identifier***";
public static String ownerID = "***provide account id****";
public static void main(String[] args) throws IOException {
AWSCredentials credentials = new PropertiesCredentials(
CreateAndModifyClusterSecurityGroup.class
API Version 2012-12-01
37
Amazon Redshift Management Guide
Associating a Security Group with a Cluster