List of usage examples for com.amazonaws.services.ec2.model DomainType Vpc
DomainType Vpc
To view the source code for com.amazonaws.services.ec2.model DomainType Vpc.
Click Source Link
From source file:aws.example.ec2.AllocateAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: AllocateAddress <instance_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);/*ww w. j a v a 2 s . c o m*/ } String instance_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); AllocateAddressRequest allocate_request = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allocate_response = ec2.allocateAddress(allocate_request); String allocation_id = allocate_response.getAllocationId(); AssociateAddressRequest associate_request = new AssociateAddressRequest().withInstanceId(instance_id) .withAllocationId(allocation_id); AssociateAddressResult associate_response = ec2.associateAddress(associate_request); System.out.printf("Successfully associated Elastic IP address %s " + "with instance %s", associate_response.getAssociationId(), instance_id); }
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * This will request a new elastic IP from Amazon and return the AllocationId * associated with that new elasticIp.//from w w w . jav a 2 s. com * * @param ec2Client * @return allocationId */ public String requestElasticIp(AmazonEC2 ec2Client) { String result = null; ; AllocateAddressRequest allReq = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allRes = ec2Client.allocateAddress(allReq); result = allRes.getAllocationId(); log.info("Elastic Ip allocated: " + allRes.getPublicIp()); log.info("Allocation Id: " + result); return result; }
From source file:ec2.AllocateAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: AllocateAddress <instance-id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);//from w w w.jav a 2 s . com } String instanceId = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); AllocateAddressRequest allocateAddressRequest = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allocateAddressResponsee = ec2.allocateAddress(allocateAddressRequest); String allocationId = allocateAddressResponsee.getAllocationId(); AssociateAddressRequest request = new AssociateAddressRequest().withInstanceId(instanceId) .withAllocationId(allocationId); AssociateAddressResult response = ec2.associateAddress(request); System.out.printf("Successfully associated elastic ip address %s with instance %s", response.getAssociationId(), instanceId); }
From source file:jp.primecloud.auto.process.aws.AwsAddressProcess.java
License:Open Source License
/** * TODO: /*from w w w . ja va 2 s .c om*/ * * @param awsProcessClient * @return */ public AwsAddress createAddress(AwsProcessClient awsProcessClient) { // Elastic IP?? AllocateAddressRequest request = new AllocateAddressRequest(); if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) { request.withDomain(DomainType.Vpc); } String publicIp; try { AllocateAddressResult result = awsProcessClient.getEc2Client().allocateAddress(request); publicIp = result.getPublicIp(); } catch (AutoException e) { // Elastic IP????? if (e.getCause() instanceof AmazonServiceException && "AddressLimitExceeded".equals(((AmazonServiceException) e.getCause()).getErrorCode())) { throw new AutoApplicationException("EPROCESS-000134"); } throw e; } // processLogger.debug(null, null, "AwsElasticIpAllocate", new Object[] { awsProcessClient.getPlatform().getPlatformName(), publicIp }); // AWS? AwsAddress awsAddress = new AwsAddress(); awsAddress.setUserNo(awsProcessClient.getUserNo()); awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo()); awsAddress.setPublicIp(publicIp); awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); awsAddressDao.create(awsAddress); return awsAddress; }