Search in sources :

Example 1 with Ec2Client

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);
            }
        }
    }
}
Also used : EC2Client(org.jclouds.aws.ec2.EC2Client)

Example 2 with Ec2Client

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);
}
Also used : EC2Client(software.amazon.awssdk.services.ec2.EC2Client) Test(org.junit.Test)

Example 3 with Ec2Client

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);
}
Also used : EC2Client(software.amazon.awssdk.services.ec2.EC2Client) Test(org.junit.Test)

Example 4 with Ec2Client

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();
}
Also used : Region(software.amazon.awssdk.regions.Region) Ec2Client(software.amazon.awssdk.services.ec2.Ec2Client)

Example 5 with Ec2Client

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();
}
Also used : Region(software.amazon.awssdk.regions.Region) Ec2Client(software.amazon.awssdk.services.ec2.Ec2Client)

Aggregations

Ec2Client (software.amazon.awssdk.services.ec2.Ec2Client)21 Region (software.amazon.awssdk.regions.Region)20 Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)16 Test (org.junit.Test)5 EC2Client (software.amazon.awssdk.services.ec2.EC2Client)5 Injector (com.google.inject.Injector)2 DescribeInstancesRequest (software.amazon.awssdk.services.ec2.model.DescribeInstancesRequest)2 DescribeInstancesResponse (software.amazon.awssdk.services.ec2.model.DescribeInstancesResponse)2 Instance (software.amazon.awssdk.services.ec2.model.Instance)2 Reservation (software.amazon.awssdk.services.ec2.model.Reservation)2 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 ListIterator (java.util.ListIterator)1 EC2Client (org.jclouds.aws.ec2.EC2Client)1 EC2AsyncClient (org.jclouds.ec2.EC2AsyncClient)1 EC2Client (org.jclouds.ec2.EC2Client)1 KeyPair (org.jclouds.ec2.domain.KeyPair)1 RunningInstance (org.jclouds.ec2.domain.RunningInstance)1 AccountAttribute (software.amazon.awssdk.services.ec2.model.AccountAttribute)1 AccountAttributeValue (software.amazon.awssdk.services.ec2.model.AccountAttributeValue)1