Search in sources :

Example 11 with CreateSecurityGroupRequest

use of software.amazon.awssdk.services.ec2.model.CreateSecurityGroupRequest in project incubator-gobblin by apache.

the class AWSSdkClient method createSecurityGroup.

/**
 * Create an Amazon AWS security group
 *
 * @param groupName Security group name
 * @param description Security group description
 */
public void createSecurityGroup(String groupName, String description) {
    AmazonEC2 amazonEC2 = getEc2Client();
    try {
        final CreateSecurityGroupRequest securityGroupRequest = new CreateSecurityGroupRequest().withGroupName(groupName).withDescription(description);
        amazonEC2.createSecurityGroup(securityGroupRequest);
        LOGGER.info("Created Security Group: " + groupName);
    } catch (AmazonServiceException ase) {
        // This might mean that security group is already created, hence ignore
        LOGGER.warn("Issue in creating security group", ase);
    }
}
Also used : AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) CreateSecurityGroupRequest(com.amazonaws.services.ec2.model.CreateSecurityGroupRequest)

Aggregations

CreateSecurityGroupRequest (com.amazonaws.services.ec2.model.CreateSecurityGroupRequest)10 IpPermission (com.amazonaws.services.ec2.model.IpPermission)5 AuthorizeSecurityGroupIngressRequest (com.amazonaws.services.ec2.model.AuthorizeSecurityGroupIngressRequest)4 AmazonServiceException (com.amazonaws.AmazonServiceException)3 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)3 CreateSecurityGroupResult (com.amazonaws.services.ec2.model.CreateSecurityGroupResult)3 Test (org.junit.Test)3 DescribeKeyPairsRequest (com.amazonaws.services.ec2.model.DescribeKeyPairsRequest)2 DescribeKeyPairsResult (com.amazonaws.services.ec2.model.DescribeKeyPairsResult)2 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)2 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)2 IpRange (com.amazonaws.services.ec2.model.IpRange)2 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)2 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 AuthorizeSecurityGroupIngressResult (com.amazonaws.services.ec2.model.AuthorizeSecurityGroupIngressResult)1 CreateKeyPairRequest (com.amazonaws.services.ec2.model.CreateKeyPairRequest)1 CreateKeyPairResult (com.amazonaws.services.ec2.model.CreateKeyPairResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 KeyPairInfo (com.amazonaws.services.ec2.model.KeyPairInfo)1