Package com.amazonaws.services.ec2.model

Examples of com.amazonaws.services.ec2.model.CreateSecurityGroupResult


        if (privateIp == null) {
            // TODO: Prune private ip addresses from NICs?
            // TODO: Need to tag??

            {
                AssignPrivateIpAddressesRequest request = new AssignPrivateIpAddressesRequest();
                request.setNetworkInterfaceId(networkInterface.getNetworkInterfaceId());
                request.setSecondaryPrivateIpAddressCount(1);
                ec2.assignPrivateIpAddresses(request);
            }

            ec2Instance = describeInstance(ec2, ec2InstanceId);
            networkInterface = findNetworkInterface(ec2Instance, networkInterfaceIndex);
            privateIp = findUnusedIp(networkInterface);

            if (privateIp == null) {
                throw new IllegalStateException("Unable to find private IP address");
            }
        }

        String privateIpAddress = privateIp.getPrivateIpAddress();

        {
            AssociateAddressRequest request = new AssociateAddressRequest();
            request.setPublicIp(vip.getData().getIp());
            request.setPrivateIpAddress(privateIpAddress);
            request.setNetworkInterfaceId(networkInterface.getNetworkInterfaceId());
            request.setInstanceId(ec2InstanceId);

            AssociateAddressResult response = ec2.associateAddress(request);
            log.info("Associated public IP with assocation id: {}", response.getAssociationId());
        }
View Full Code Here


        }

        String privateIpAddress = privateIp.getPrivateIpAddress();

        {
            AssociateAddressRequest request = new AssociateAddressRequest();
            request.setPublicIp(vip.getData().getIp());
            request.setPrivateIpAddress(privateIpAddress);
            request.setNetworkInterfaceId(networkInterface.getNetworkInterfaceId());
            request.setInstanceId(ec2InstanceId);

            AssociateAddressResult response = ec2.associateAddress(request);
            log.info("Associated public IP with assocation id: {}", response.getAssociationId());
        }
View Full Code Here

            request.setPublicIp(vip.getData().getIp());
            request.setPrivateIpAddress(privateIpAddress);
            request.setNetworkInterfaceId(networkInterface.getNetworkInterfaceId());
            request.setInstanceId(ec2InstanceId);

            AssociateAddressResult response = ec2.associateAddress(request);
            log.info("Associated public IP with assocation id: {}", response.getAssociationId());
        }

        return privateIpAddress;
    }
View Full Code Here

      for (GroupIdentifier g : this.instance.getSecurityGroups()) {
        IpPermission ip = new IpPermission();
        ip.setIpProtocol("tcp");
        ip.setFromPort(22);
        ip.setToPort(22);
        AuthorizeSecurityGroupIngressRequest r = new AuthorizeSecurityGroupIngressRequest();
        r = r.withIpPermissions(ip.withIpRanges("0.0.0.0/0"));
        r.setGroupId(g.getGroupId());
        try {
          ec2client.authorizeSecurityGroupIngress(r);
        } catch (AmazonServiceException as) {
          /*
           * If exception is from duplicate room, ignore it.
View Full Code Here

  }

  public Image imageRegister(final String instanceId, final String name,
      final String description) throws Exception {

    final CreateImageRequest request = new CreateImageRequest();

    request.setInstanceId(instanceId);
    request.setName(name);
    request.setDescription(description);

    final CreateImageResult result = amazonClient.createImage(request);

    final String imageId = result.getImageId();
View Full Code Here

    request.setInstanceId(instanceId);
    request.setName(name);
    request.setDescription(description);

    final CreateImageResult result = amazonClient.createImage(request);

    final String imageId = result.getImageId();

    logger.info("register imageId=" + imageId);

    final Image image = waitForImage(imageId);
View Full Code Here

        // Create a new security group.
        try {
            CreateSecurityGroupRequest securityGroupRequest = new CreateSecurityGroupRequest(
                    "GettingStartedGroup", "Getting Started Security Group");
            CreateSecurityGroupResult result = ec2
                    .createSecurityGroup(securityGroupRequest);
            System.out.println(String.format("Security group created: [%s]",
                    result.getGroupId()));
        } catch (AmazonServiceException ase) {
            // Likely this means that the group is already created, so ignore.
            System.out.println(ase.getMessage());
        }
View Full Code Here

        try {
            LOG.info(">> Creating Security Group with name {}", groupName);
            CreateSecurityGroupRequest request = new CreateSecurityGroupRequest()
                .withGroupName(groupName).withDescription("Security Group for " + businessKey);

            CreateSecurityGroupResult result = client.createSecurityGroup(request);
            LOG.info("<< Created Security Group with ID {}", result.getGroupId());

        } catch (AmazonServiceException e) {
            if (e.getErrorCode().equals(ErrorCodes.DUPLICATE_SECURITY_GROUP)) {
                LOG.warn(String.format("<< Security Group %s already exists. " +
                    "Synchronizing ingress rules.", groupName), e);
View Full Code Here

        request.setDescription(description);
        request.setVpcId(vpcId);

        LOGGER.info(String.format("Creating EC2 security group %s.", name));

        CreateSecurityGroupResult result = ec2Client.createSecurityGroup(request);
        return result.getGroupId();
    }
View Full Code Here

        try {
            LOG.info(">> Creating Security Group with name {}", groupName);
            CreateSecurityGroupRequest request = new CreateSecurityGroupRequest()
                .withGroupName(groupName).withDescription("Security Group for " + businessKey);

            CreateSecurityGroupResult result = client.createSecurityGroup(request);
            LOG.info("<< Created Security Group with ID {}", result.getGroupId());

        } catch (AmazonServiceException e) {
            if (e.getErrorCode().equals(ErrorCodes.DUPLICATE_SECURITY_GROUP)) {
                LOG.warn(String.format("<< Security Group %s already exists. " +
                    "Synchronizing ingress rules.", groupName), e);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.ec2.model.CreateSecurityGroupResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.