当前位置: 首页>>代码示例>>Java>>正文


Java AmazonEC2ClientBuilder类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.AmazonEC2ClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java AmazonEC2ClientBuilder类的具体用法?Java AmazonEC2ClientBuilder怎么用?Java AmazonEC2ClientBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AmazonEC2ClientBuilder类属于com.amazonaws.services.ec2包,在下文中一共展示了AmazonEC2ClientBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEC2SynchronousClient

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static AmazonEC2 getEC2SynchronousClient(AuthCredentialsServiceState credentials,
        String region) {
    ClientConfiguration configuration = new ClientConfiguration();
    configuration.withRetryPolicy(new RetryPolicy(new CustomRetryCondition(),
            DEFAULT_BACKOFF_STRATEGY,
            DEFAULT_MAX_ERROR_RETRY,
            true));

    AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(credentials.privateKeyId,
                    EncryptionUtils.decrypt(credentials.privateKey)));

    AmazonEC2ClientBuilder ec2ClientBuilder = AmazonEC2ClientBuilder.standard()
            .withCredentials(awsStaticCredentialsProvider)
            .withRegion(region)
            .withClientConfiguration(configuration);

    return ec2ClientBuilder.build();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestUtils.java

示例2: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply an instance id\n" +
        "Ex: RebootInstnace <instance_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String instance_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    RebootInstancesRequest request = new RebootInstancesRequest()
        .withInstanceIds(instance_id);

    RebootInstancesResult response = ec2.rebootInstances(request);

    System.out.printf(
        "Successfully rebooted instance %s", instance_id);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:RebootInstance.java

示例3: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a security group id\n" +
        "Ex: DeleteSecurityGroup <security-group-id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String group_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DeleteSecurityGroupRequest request = new DeleteSecurityGroupRequest()
        .withGroupId(group_id);

    DeleteSecurityGroupResult response = ec2.deleteSecurityGroup(request);

    System.out.printf(
        "Successfully deleted security group with id %s", group_id);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:DeleteSecurityGroup.java

示例4: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeAddressesResult response = ec2.describeAddresses();

    for(Address address : response.getAddresses()) {
        System.out.printf(
                "Found address with public IP %s, " +
                "domain %s, " +
                "allocation id %s " +
                "and NIC id %s",
                address.getPublicIp(),
                address.getDomain(),
                address.getAllocationId(),
                address.getNetworkInterfaceId());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:19,代码来源:DescribeAddresses.java

示例5: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a key pair name\n" +
        "Ex: CreateKeyPair <key-pair-name>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String key_name = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    CreateKeyPairRequest request = new CreateKeyPairRequest()
        .withKeyName(key_name);

    CreateKeyPairResult response = ec2.createKeyPair(request);

    System.out.printf(
        "Successfulyl created key pair named %s",
        key_name);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:25,代码来源:CreateKeyPair.java

示例6: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply an allocation ID.\n" +
        "Ex: ReleaseAddress <allocation_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String alloc_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    ReleaseAddressRequest request = new ReleaseAddressRequest()
        .withAllocationId(alloc_id);

    ReleaseAddressResult response = ec2.releaseAddress(request);

    System.out.printf(
        "Successfully released elastic IP address %s", alloc_id);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:ReleaseAddress.java

示例7: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a key pair name\n" +
        "Ex: DeleteKeyPair <key-pair-name>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String key_name = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DeleteKeyPairRequest request = new DeleteKeyPairRequest()
        .withKeyName(key_name);

    DeleteKeyPairResult response = ec2.deleteKeyPair(request);

    System.out.printf(
        "Successfully deleted key pair named %s", key_name);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:DeleteKeyPair.java

示例8: checkTagsAws

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
protected static void checkTagsAws(Regions region, List<String> instanceIdList, Map<String, String> tagsToCheckMap) {
    Map<String, String> extractedTagsToCheck = new HashMap<>();
    List<Tag> extractedTags;
    AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(region).build();
    DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
    describeInstancesRequest.withInstanceIds(instanceIdList);
    DescribeInstancesResult describeInstancesResultAll = ec2.describeInstances(describeInstancesRequest);
    List<Reservation> reservationsAll = describeInstancesResultAll.getReservations();
    for (Reservation reservation : reservationsAll) {
        for (Instance instance : reservation.getInstances()) {
            extractedTags = instance.getTags();
            Assert.assertNotNull(extractedTags);
            for (Tag tag : extractedTags) {
                extractedTagsToCheck.put(tag.getKey(), tag.getValue());
            }
            checkTags(tagsToCheckMap, extractedTagsToCheck);
            extractedTags.clear();
        }
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:21,代码来源:TagsUtil.java

示例9: amazonEC2Client

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
@Bean
public AmazonEC2 amazonEC2Client(final AWSCredentialsProvider awsCredentialsProvider,
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonEC2ClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:10,代码来源:AwsConfig.java

示例10: AAWSTest

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public AAWSTest() {
    super();
    if (Config.has(Config.Key.IAM_ROLE_ARN)) {
        final AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withCredentials(new DefaultAWSCredentialsProviderChain()).build();
        this.credentialsProvider = new STSAssumeRoleSessionCredentialsProvider.Builder(Config.get(Config.Key.IAM_ROLE_ARN), IAM_SESSION_NAME).withStsClient(sts).build();
    } else {
        this.credentialsProvider = new DefaultAWSCredentialsProviderChain();
    }
    this.ec2 = AmazonEC2ClientBuilder.standard().withCredentials(this.credentialsProvider).build();
    this.iam = AmazonIdentityManagementClientBuilder.standard().withCredentials(this.credentialsProvider).build();
}
 
开发者ID:widdix,项目名称:aws-ec2-ssh,代码行数:12,代码来源:AAWSTest.java

示例11: EBMetricsFetcher

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public EBMetricsFetcher() throws CandlestackException {
	super( EBUtil.TYPE_NAME, GlobalAWSProperties.getEBMetricsFetcherSleep() );

	environmentNamePrefix = GlobalAWSProperties.getEBEnvrionmentNamePrefix();
	environmentNameRegex = GlobalAWSProperties.getEBEnvrionmentNameRegex();

	ec2CloudWatchMetrics = GlobalAWSProperties.getEC2CloudwatchMetricsToFetch();
	ebCloudWatchMetrics = GlobalAWSProperties.getEBCloudwatchMetricsToFetch();

	String region = GlobalAWSProperties.getRegion();
	beanstalkClient = AWSElasticBeanstalkClientBuilder.standard().withRegion( region ).build();
	ec2Client = AmazonEC2ClientBuilder.standard().withRegion( region ).build();

	cloudWatchAccessor = CloudWatchAccessor.getInstance();
}
 
开发者ID:CodeArcsInc,项目名称:candlestack,代码行数:16,代码来源:EBMetricsFetcher.java

示例12: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeRegionsResult regions_response = ec2.describeRegions();

    for(Region region : regions_response.getRegions()) {
        System.out.printf(
            "Found region %s " +
            "with endpoint %s",
            region.getRegionName(),
            region.getEndpoint());
    }

    DescribeAvailabilityZonesResult zones_response =
        ec2.describeAvailabilityZones();

    for(AvailabilityZone zone : zones_response.getAvailabilityZones()) {
        System.out.printf(
            "Found availability zone %s " +
            "with status %s " +
            "in region %s",
            zone.getZoneName(),
            zone.getState(),
            zone.getRegionName());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:DescribeRegionsAndZones.java

示例13: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeKeyPairsResult response = ec2.describeKeyPairs();

    for(KeyPairInfo key_pair : response.getKeyPairs()) {
        System.out.printf(
            "Found key pair with name %s " +
            "and fingerprint %s",
            key_pair.getKeyName(),
            key_pair.getKeyFingerprint());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:15,代码来源:DescribeKeyPairs.java

示例14: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a group id\n" +
        "Ex: DescribeSecurityGroups <group-id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String group_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DescribeSecurityGroupsRequest request =
        new DescribeSecurityGroupsRequest()
            .withGroupIds(group_id);

    DescribeSecurityGroupsResult response =
        ec2.describeSecurityGroups(request);

    for(SecurityGroup group : response.getSecurityGroups()) {
        System.out.printf(
            "Found security group with id %s, " +
            "vpc id %s " +
            "and description %s",
            group.getGroupId(),
            group.getVpcId(),
            group.getDescription());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:33,代码来源:DescribeSecurityGroups.java

示例15: main

import com.amazonaws.services.ec2.AmazonEC2ClientBuilder; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
    boolean done = false;

    while(!done) {
        DescribeInstancesRequest request = new DescribeInstancesRequest();
        DescribeInstancesResult response = ec2.describeInstances(request);

        for(Reservation reservation : response.getReservations()) {
            for(Instance instance : reservation.getInstances()) {
                System.out.printf(
                    "Found reservation with id %s, " +
                    "AMI %s, " +
                    "type %s, " +
                    "state %s " +
                    "and monitoring state %s",
                    instance.getInstanceId(),
                    instance.getImageId(),
                    instance.getInstanceType(),
                    instance.getState().getName(),
                    instance.getMonitoring().getState());
            }
        }

        request.setNextToken(response.getNextToken());

        if(response.getNextToken() == null) {
            done = true;
        }
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:33,代码来源:DescribeInstances.java


注:本文中的com.amazonaws.services.ec2.AmazonEC2ClientBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。