0

I am adding tags to load balancer in java using below code:

AmazonElasticLoadBalancingClient elbClient = new AmazonElasticLoadBalancingClient(credentials);
AddTagsRequest addTagReq = new AddTagsRequest();
addTagReq.setTags("Name","Value");

However , it is giving compile error in setTags.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
Aquarius24
  • 1,806
  • 6
  • 33
  • 61

1 Answers1

0

even though each tag consists of a key and an optional value, you cannot directly add tags like a map, you first need to declare a collection of Tags:

AmazonElasticLoadBalancingClient elbClient = new AmazonElasticLoadBalancingClient(credentials);

ArrayList<Tag> requestTags = new ArrayList<Tag>();
requestTags.add(new Tag("keyname1","value1"));

AddTagsRequest addTagReq = new AddTagsRequest();
addTagReq.setTags(requestTags);

elbClient.addTags(addTagReq);
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139