use of software.amazon.awssdk.services.ec2.Ec2Client in project whirr by apache.
the class FirewallSettings method authorizeIngress.
private static void authorizeIngress(ComputeServiceContext computeServiceContext, Set<? extends NodeMetadata> nodes, ClusterSpec clusterSpec, List<String> cidrs, int... ports) {
if (clusterSpec.getProvider().equals("ec2")) {
// This code (or something like it) may be added to jclouds (see
// http://code.google.com/p/jclouds/issues/detail?id=336).
// Until then we need this temporary workaround.
String region = EC2Utils.parseHandle(Iterables.get(nodes, 0).getId())[0];
EC2Client ec2Client = EC2Client.class.cast(computeServiceContext.getProviderSpecificContext().getApi());
String groupName = "jclouds#" + clusterSpec.getClusterName();
for (String cidr : cidrs) {
for (int port : ports) {
ec2Client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, groupName, IpProtocol.TCP, port, port, cidr);
}
}
}
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project iep by Netflix.
the class AwsClientFactoryTest method newInstanceName.
@Test
public void newInstanceName() throws Exception {
AwsClientFactory factory = new AwsClientFactory(config);
EC2Client ec2 = factory.newInstance("ec2-test", EC2Client.class);
Assert.assertNotNull(ec2);
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project iep by Netflix.
the class AwsClientFactoryTest method newInstanceClient.
@Test
public void newInstanceClient() throws Exception {
AwsClientFactory factory = new AwsClientFactory(config);
EC2Client ec2 = factory.newInstance(EC2Client.class);
Assert.assertNotNull(ec2);
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class ReleaseAddress method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <allocId>\n\n" + "Where:\n" + " allocId - an allocation ID value that you can obtain from the AWS Console. \n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String allocId = args[0];
Region region = Region.US_WEST_2;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
releaseEC2Address(ec2, allocId);
ec2.close();
}
use of software.amazon.awssdk.services.ec2.Ec2Client in project aws-doc-sdk-examples by awsdocs.
the class TerminateInstance method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <instanceId>\n\n" + "Where:\n" + " instanceId - an instance id value that you can obtain from the AWS Console. \n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String instanceId = args[0];
Region region = Region.US_EAST_1;
Ec2Client ec2 = Ec2Client.builder().region(region).build();
terminateEC2(ec2, instanceId);
ec2.close();
}
Aggregations