List of usage examples for com.amazonaws.services.ec2.model CreateSecurityGroupRequest setDescription
public void setDescription(String description)
A description for the security group.
From source file:com.hpcloud.daas.ec2.AwsConsoleApp.java
License:Open Source License
public static void CreateSecurityGroup(String name, String description) throws Exception { try {/*from www . java2s. com*/ CreateSecurityGroupRequest newSecurityGroup = new CreateSecurityGroupRequest(); newSecurityGroup.setDescription(description); newSecurityGroup.setGroupName(name); ec2.createSecurityGroup(newSecurityGroup); System.out.println("Security group created : " + name); } catch (AmazonServiceException ase) { System.out.println("Error : Adding new security group"); System.out.println("Caught Exception: " + ase.getMessage()); System.out.println("Reponse Status Code: " + ase.getStatusCode()); System.out.println("Error Code: " + ase.getErrorCode()); System.out.println("Request ID: " + ase.getRequestId()); } }
From source file:com.netflix.simianarmy.client.aws.AWSClient.java
License:Apache License
/** {@inheritDoc} */ public String createSecurityGroup(String instanceId, String name, String description) { String vpcId = getVpcId(instanceId); AmazonEC2 ec2Client = ec2Client();//from w w w .j ava2 s . c om CreateSecurityGroupRequest request = new CreateSecurityGroupRequest(); request.setGroupName(name); request.setDescription(description); request.setVpcId(vpcId); LOGGER.info(String.format("Creating EC2 security group %s.", name)); CreateSecurityGroupResult result = ec2Client.createSecurityGroup(request); return result.getGroupId(); }
From source file:org.apache.stratos.aws.extension.AWSHelper.java
License:Apache License
/** * Creates security group with the given name in the given region * * @param groupName to be created/*from www .j a va2s . co m*/ * @param description * @param region in which the security group to be created * @return Id of the security group created * @throws LoadBalancerExtensionException */ public String createSecurityGroup(String groupName, String description, String region, String vpcId) throws LoadBalancerExtensionException { if (groupName == null || groupName.isEmpty()) { throw new LoadBalancerExtensionException("Invalid Security Group Name."); } CreateSecurityGroupRequest createSecurityGroupRequest = new CreateSecurityGroupRequest(); createSecurityGroupRequest.setGroupName(groupName); createSecurityGroupRequest.setDescription(description); if (vpcId != null) { createSecurityGroupRequest.setVpcId(vpcId); } try { ec2Client.setEndpoint(String.format(Constants.EC2_ENDPOINT_URL_FORMAT, region)); CreateSecurityGroupResult createSecurityGroupResult = ec2Client .createSecurityGroup(createSecurityGroupRequest); return createSecurityGroupResult.getGroupId(); } catch (AmazonClientException e) { log.error("Could not create security group.", e); throw new LoadBalancerExtensionException("Could not create security group.", e); } }
From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java
License:Apache License
public String createSecurityGroup(String groupName, String description) { CreateSecurityGroupResult result = null; try {//from w ww.ja va 2 s. c om CreateSecurityGroupRequest request = new CreateSecurityGroupRequest(); request.setDescription(description); request.setGroupName(groupName); result = ec2.createSecurityGroup(request); } catch (Exception e) { String message = e.getMessage(); LOG.error("Error creating security group: " + message); ExceptionUtil.throwSystemException(message, e); } return result.getGroupId(); }