/** * Makes a call to the operation specified by the waiter by taking the corresponding request and returns the * corresponding result * * @param describeVpcsRequest * Corresponding request for the operation * @return Corresponding result of the operation */ @Override public DescribeVpcsResult apply(DescribeVpcsRequest describeVpcsRequest) { return client.describeVpcs(describeVpcsRequest); } }
/** * Makes a call to the operation specified by the waiter by taking the corresponding request and returns the * corresponding result * * @param describeVpcsRequest * Corresponding request for the operation * @return Corresponding result of the operation */ @Override public DescribeVpcsResult apply(DescribeVpcsRequest describeVpcsRequest) { return client.describeVpcs(describeVpcsRequest); } }
/** * Gets the vpcs for region. * * @param ec2ServiceClient the ec 2 service client * @param region the region * @param request the request * @return the vpcs for region */ public static List<Vpc> getVpcsForRegion(AmazonEC2 ec2ServiceClient, Region region, DescribeVpcsRequest request) { ec2ServiceClient.setRegion(region); DescribeVpcsResult describeVpcsResult = ec2ServiceClient.describeVpcs(request); return describeVpcsResult.getVpcs(); }
public boolean existsInAws() { // since we have an id, check if Vpc exists in AWS boolean result = false; DescribeVpcsRequest vpcReq = new DescribeVpcsRequest().withVpcIds(vpcId); if (context.fetchEC2Client().describeVpcs(vpcReq) == null) { log.info("Vpc with id " + vpcId + " does NOT exist in AWS!"); } else { result = true; } return result; }
private Map<String, String> getVpcMappings(List<NetflixAmazonCredentials> accounts) { Map<String, String> mappings = new HashMap<>(); if (target.getVpcId() == null) { return mappings; } AmazonEC2 baseTarget = getAmazonClientProvider().getAmazonEC2(target.getCredentials(), target.getRegion()); Vpc targetVpc = baseTarget.describeVpcs().getVpcs().stream() .filter(vpc -> vpc.getVpcId().equals(target.getVpcId())) .findFirst().orElse(null); String targetName = AmazonVpcProvider.getVpcName(targetVpc); accounts.forEach(account -> { List<Vpc> vpcs = getAmazonClientProvider().getAmazonEC2(account, target.getRegion()).describeVpcs().getVpcs(); Vpc match = vpcs.stream() .filter(vpc -> AmazonVpcProvider.getVpcName(vpc).equals(targetName)) .findFirst().orElse(null); mappings.put(account.getAccountId(), match.getVpcId()); }); return mappings; }
List<VpcVH> vpcList = new ArrayList<>(); AmazonEC2 ec2Client = AmazonEC2ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); List<Vpc> tmpVpcList = ec2Client.describeVpcs().getVpcs(); tmpVpcList.stream().forEach(vpc -> { VpcVH vpcVH = new VpcVH();
private Vpc getVpc(LoadBalancerLocation source) { if (source.getVpcId() != null) { DescribeVpcsResult vpcLookup = getAmazonClientProvider().getAmazonEC2(source.getCredentials(), source.getRegion()) .describeVpcs(new DescribeVpcsRequest().withVpcIds(source.getVpcId())); if (vpcLookup.getVpcs().isEmpty()) { throw new IllegalStateException(String.format("Could not find VPC %s in %s/%s", source.getVpcId(), source.getCredentialAccount(), source.getRegion())); } return vpcLookup.getVpcs().get(0); } return null; }
AmazonEC2 ec2 = amazonClientProvider.getAmazonEC2(credentialsProvider, AmazonClientProvider.DEFAULT_REGION); try { List<Vpc> vpcs = ec2.describeVpcs().getVpcs(); boolean supportsByName = false; if (vpcs.isEmpty()) {