public class EC2Api extends Object
Constructor and Description |
---|
EC2Api() |
Modifier and Type | Method and Description |
---|---|
com.amazonaws.services.ec2.AmazonEC2 |
connect(String awsCredentialsId,
String regionName,
String endpoint) |
Map<String,com.amazonaws.services.ec2.model.Instance> |
describeInstances(com.amazonaws.services.ec2.AmazonEC2 ec2,
Set<String> instanceIds) |
Map<String,com.amazonaws.services.ec2.model.Instance> |
describeInstances(com.amazonaws.services.ec2.AmazonEC2 ec2,
Set<String> instanceIds,
int batchSize) |
String |
getEndpoint(String regionName,
String endpoint)
Derive EC2 API endpoint.
|
void |
tagInstances(com.amazonaws.services.ec2.AmazonEC2 ec2,
Set<String> instanceIds,
String key,
String value) |
void |
terminateInstances(com.amazonaws.services.ec2.AmazonEC2 ec2,
Collection<String> instanceIds)
Auto handle instance not found exception if any and assume those instances as already terminated
|
public Map<String,com.amazonaws.services.ec2.model.Instance> describeInstances(com.amazonaws.services.ec2.AmazonEC2 ec2, Set<String> instanceIds)
public Map<String,com.amazonaws.services.ec2.model.Instance> describeInstances(com.amazonaws.services.ec2.AmazonEC2 ec2, Set<String> instanceIds, int batchSize)
public void terminateInstances(com.amazonaws.services.ec2.AmazonEC2 ec2, Collection<String> instanceIds)
ec2
- ec2 clientinstanceIds
- set of instance idspublic void tagInstances(com.amazonaws.services.ec2.AmazonEC2 ec2, Set<String> instanceIds, String key, String value)
public com.amazonaws.services.ec2.AmazonEC2 connect(String awsCredentialsId, String regionName, String endpoint)
@Nullable public String getEndpoint(@Nullable String regionName, @Nullable String endpoint)
endpoint
parameter not empty will use
it as first priority, otherwise will try to find region in RegionUtils
by regionName
and use endpoint from it, if not available will generate endpoint as string and check if
region name looks like China cn-
prefix.
Implementation details
RegionUtils
is static information, and to get new region required to be updated,
as it's not possible too fast as you need to check new version of lib, moreover new version of lib
could be pointed to new version of Jenkins which is not a case for our plugin as some of installation
still on 1.6.x
For example latest AWS SDK lib depends on Jackson2 plugin which starting from version 2.8.7.0
require Jenkins at least 2.60
https://plugins.jenkins.io/jackson2-api
List of all AWS endpoints https://docs.aws.amazon.com/general/latest/gr/rande.html
regionName
- like us-east-1 not a airport code, could be null
endpoint
- custom endpoint could be null
null
or actual endpointCopyright © 2016–2023. All rights reserved.