use of com.amazonaws.services.ec2.model.CreateTagsRequest in project SimianArmy by Netflix.
the class AWSClient method createTagsForResources.
@Override
public void createTagsForResources(Map<String, String> keyValueMap, String... resourceIds) {
Validate.notNull(keyValueMap);
Validate.notEmpty(keyValueMap);
Validate.notNull(resourceIds);
Validate.notEmpty(resourceIds);
AmazonEC2 ec2Client = ec2Client();
List<Tag> tags = new ArrayList<Tag>();
for (Map.Entry<String, String> entry : keyValueMap.entrySet()) {
tags.add(new Tag(entry.getKey(), entry.getValue()));
}
CreateTagsRequest req = new CreateTagsRequest(Arrays.asList(resourceIds), tags);
ec2Client.createTags(req);
}
use of com.amazonaws.services.ec2.model.CreateTagsRequest in project GNS by MobilityFirst.
the class AWSEC2 method addInstanceTag.
/**
* Adds the key and value as a 'tag' for the instance.
*
* @param ec2
* @param createdInstanceId
* @param key
* @param value
*/
public static void addInstanceTag(AmazonEC2 ec2, String createdInstanceId, String key, String value) {
List<String> resources = new LinkedList<>();
resources.add(createdInstanceId);
List<Tag> tags = new LinkedList<>();
Tag nameTag = new Tag(key, value);
tags.add(nameTag);
CreateTagsRequest ctr = new CreateTagsRequest(resources, tags);
ec2.createTags(ctr);
}
use of com.amazonaws.services.ec2.model.CreateTagsRequest in project photon-model by vmware.
the class AWSUtils method tagResources.
/**
* Synchronous Tagging of one or many AWS resources with the provided tags.
*/
public static void tagResources(AmazonEC2AsyncClient client, Collection<Tag> tags, String... resourceIds) {
if (isAwsClientMock()) {
return;
}
CreateTagsRequest req = new CreateTagsRequest().withResources(resourceIds).withTags(tags);
client.createTags(req);
}
use of com.amazonaws.services.ec2.model.CreateTagsRequest in project cloudbreak by hortonworks.
the class AwsMetadataCollector method addTag.
private void addTag(AmazonEC2 amazonEC2Client, CloudInstance cloudInstance, Instance instance) {
String tagName = awsClient.getCbName(cloudInstance.getTemplate().getGroupName(), cloudInstance.getTemplate().getPrivateId());
Tag t = new Tag();
t.setKey(TAG_NAME);
t.setValue(tagName);
CreateTagsRequest ctr = new CreateTagsRequest();
ctr.setTags(Collections.singletonList(t));
ctr.withResources(instance.getInstanceId());
amazonEC2Client.createTags(ctr);
}
Aggregations