private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.ec2.model.AmazonEC2Exception.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("https://ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/ec2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
/** * All public methods except <code>terminateInstances</code> use supplied arguments * to set the appropriate data center. So this is only needed before calling <code>terminateInstances</code>. * * @param dataCenter Ec2Client's endpoint, us-east-1, us-west-2 etc. */ @Override public void setDataCenter( final String dataCenter ) { client.setEndpoint( AmazonUtils.getEndpoint( dataCenter ) ); }
/** * Note that you have to set the data center before any other operation, * if you are to use a different data center than Amazon's default */ @Override public void setDataCenter( final String dataCenter ) { client.setEndpoint( AmazonUtils.getEndpoint( dataCenter ) ); }
private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.ec2.model.AmazonEC2Exception.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("https://ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/ec2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
/** * @param stack <code>ICoordinatedStack</code> object containing the <code>cluster</code> * @param cluster * @return Cluster instances which are in <code>Running</code> state */ @Override public Collection<Instance> getClusterInstances( ICoordinatedStack stack, ICoordinatedCluster cluster ) { String name = getInstanceName( stack, cluster ); if( stack.getDataCenter() != null && ! stack.getDataCenter().isEmpty() ) { client.setEndpoint( AmazonUtils.getEndpoint( stack.getDataCenter() ) ); } return toInstances( getEC2Instances( name, InstanceStateName.Running ) ); }
/** * @param stack * @return Runner instances which belong to <code>stack</code> and in <code>Running</code> state */ @Override public Collection<Instance> getRunnerInstances( ICoordinatedStack stack ) { String name = getRunnerName( stack ); if( stack.getDataCenter() != null && ! stack.getDataCenter().isEmpty() ) { client.setEndpoint( AmazonUtils.getEndpoint( stack.getDataCenter() ) ); } return toInstances( getEC2Instances( name, InstanceStateName.Running ) ); }
ec2.setEndpoint("ec2." + region + ".amazonaws.com"); DescribeInstancesResult describeInstancesResult = ec2.describeInstances(); List<Reservation> reservations = describeInstancesResult.getReservations();
client.setEndpoint( AmazonUtils.getEndpoint( stack.getDataCenter() ) );
client.setEndpoint( AmazonUtils.getEndpoint( stack.getDataCenter() ) );
private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/ec2/request.handler2s")); }
@Bean @ConditionalOnProperty("aws.accessKeyId") AmazonEC2Client amazonEC2(@Value("${aws.accessKeyId}") String accessKeyId, @Value("${aws.secretAccessKey}") String secretAccessKey, @Value("${aws.region:us-east-1}") String regionName) { AmazonEC2Client amazonEC2Client = new AmazonEC2Client(new BasicAWSCredentials(accessKeyId, secretAccessKey)); Region region = Region.getRegion(Regions.fromName(regionName)); amazonEC2Client.setEndpoint(region.getServiceEndpoint("ec2")); return amazonEC2Client; }
@Provides @Singleton public AmazonEC2 provideAmazonEC2(AwsProvisionerConfig provisionerConfig, AWSCredentials awsCredentials) { AmazonEC2Client client = new AmazonEC2Client(awsCredentials); //Use the config to override the default endpoint in the ec2 client. if (provisionerConfig.getAwsEndpoint() != null) { client.setEndpoint(provisionerConfig.getAwsEndpoint()); } return client; }
@Provides @Singleton public AmazonEC2 provideAmazonEC2(AwsProvisionerConfig provisionerConfig, AWSCredentials awsCredentials) { AmazonEC2Client client = new AmazonEC2Client(awsCredentials); //Use the config to override the default endpoint in the ec2 client. if (provisionerConfig.getAwsEndpoint() != null) { client.setEndpoint(provisionerConfig.getAwsEndpoint()); } return client; }
/** * Creates a new AwsVMManager instance using * the reagion from the properties file */ public AwsVmManager() { awsProperties = initAWSProperties(); this.region = awsProperties.getProperty("region"); /** * By default we use the credentials provided in the configuration files. * If there are none we fall back to IAM roles. */ try { credentials = getCredentials(); client = new AmazonEC2Client(credentials); } catch (IllegalArgumentException e) { log.info("Falling back to IAM roles for authorization since no credentials provided in system properties", e); client = new AmazonEC2Client(); } client.setEndpoint(awsProperties.getProperty(region + "_endpoint")); }
public static AmazonEC2Client getClient(EC2ServiceContext context) { AmazonEC2Client client = newAmazonEC2Client(context); if (context.getTimeOffsetInSeconds().isPresent()) { client.setTimeOffset(context.getTimeOffsetInSeconds().get()); } client.setRegion(RegionUtils.getRegion(context.getRegion())); if (context.getEndpoint().isPresent()) { client.setEndpoint(context.getEndpoint().get()); } return client; }
private static AmazonEC2 connect(final String credentialsId, final String region) { final AmazonWebServicesCredentials credentials = AWSCredentialsHelper.getCredentials(credentialsId, Jenkins.getInstance()); final AmazonEC2Client client = credentials != null ? new AmazonEC2Client(credentials) : new AmazonEC2Client(); if (region != null) client.setEndpoint("https://ec2." + region + ".amazonaws.com/"); return client; }
public Ec2CloudHost(String hostLabel, String amiId) { this.hostLabel = hostLabel; this.amiId = amiId; this.awsEndpointURL = getOvercastProperty(AWS_ENDPOINT_PROPERTY, AWS_ENDPOINT_DEFAULT); this.awsAccessKey = getRequiredOvercastProperty(AWS_ACCESS_KEY_PROPERTY); this.awsSecretKey = getRequiredOvercastProperty(AWS_SECRET_KEY_PROPERTY); this.amiAvailabilityZone = getOvercastProperty(hostLabel + AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX, null); this.amiInstanceType = getRequiredOvercastProperty(hostLabel + AMI_INSTANCE_TYPE_PROPERTY_SUFFIX); this.amiSecurityGroup = getRequiredOvercastProperty(hostLabel + AMI_SECURITY_GROUP_PROPERTY_SUFFIX); this.amiKeyName = getRequiredOvercastProperty(hostLabel + AMI_KEY_NAME_PROPERTY_SUFFIX); this.amiBootSeconds = Integer.valueOf(getRequiredOvercastProperty(hostLabel + AMI_BOOT_SECONDS_PROPERTY_SUFFIX)); ec2 = new AmazonEC2Client(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); ec2.setEndpoint(awsEndpointURL); }
public Ec2ItestHost(String hostLabel, String amiId) { this.hostLabel = hostLabel; this.amiId = amiId; this.awsEndpointURL = getItestProperty(AWS_ENDPOINT_PROPERTY, AWS_ENDPOINT_DEFAULT); this.awsAccessKey = getRequiredItestProperty(AWS_ACCESS_KEY_PROPERTY); this.awsSecretKey = getRequiredItestProperty(AWS_SECRET_KEY_PROPERTY); this.amiAvailabilityZone = getItestProperty(hostLabel + AMI_AVAILABILITY_ZONE_PROPERTY_SUFFIX, null); this.amiInstanceType = getRequiredItestProperty(hostLabel + AMI_INSTANCE_TYPE_PROPERTY_SUFFIX); this.amiSecurityGroup = getRequiredItestProperty(hostLabel + AMI_SECURITY_GROUP_PROPERTY_SUFFIX); this.amiKeyName = getRequiredItestProperty(hostLabel + AMI_KEY_NAME_PROPERTY_SUFFIX); this.amiBootSeconds = Integer.valueOf(getRequiredItestProperty(hostLabel + AMI_BOOT_SECONDS_PROPERTY_SUFFIX)); ec2 = new AmazonEC2Client(new BasicAWSCredentials(awsAccessKey, awsSecretKey)); ec2.setEndpoint(awsEndpointURL); }
public AwsGatlingRunner(final String endpoint) { final AWSCredentialsProviderChain credentials = new AWSCredentialsProviderChain( new PropertiesFileCredentialsProvider("aws.properties"), new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider()); this.ec2client = new AmazonEC2Client(credentials); this.ec2client.setEndpoint(endpoint); this.transferManager = new TransferManager(credentials); }
/** * Perform the query and return the set of instances * */ public NodeSetImpl performQuery() { final NodeSetImpl nodeSet = new NodeSetImpl(); final AmazonEC2Client ec2 ; if(null!=credentials) { ec2 = new AmazonEC2Client(credentials, clientConfiguration); } else{ ec2 = new AmazonEC2Client(clientConfiguration); } if (null != getEndpoint()) { ec2.setEndpoint(getEndpoint()); } final ArrayList<Filter> filters = buildFilters(); final Set<Instance> instances = query(ec2, new DescribeInstancesRequest().withFilters(filters).withMaxResults(maxResults)); mapInstances(nodeSet, instances); return nodeSet; }