Skip to content

Commit

Permalink
Fixed aws-api ec2 use of filters (#179)
Browse files Browse the repository at this point in the history
* Fixed aws-api ec2 use of tags

The withFilters method of AWS' DescribeInstancesRequest is always a set
operation when used with a collection. Ec2TagBasedSimpleServiceDiscovery
chains calls to withFilters and ends the chain by passing a collection
to the method, which effectively drops all filters previously set.
This change merges all ec2 filters in a single java list before building
the DescribeInstancesRequest.

* Update list syntax
  • Loading branch information
fabienrenaud authored and ktoso committed Apr 19, 2018
1 parent 585c118 commit 0582918
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ class Ec2TagBasedSimpleServiceDiscovery(system: ActorSystem) extends SimpleServi
val otherFiltersString =
system.settings.config.getConfig("akka.discovery.aws-api-ec2-tag-based").getString("filters")

val otherFilters: util.List[Filter] = parseFiltersString(otherFiltersString).asJava
val otherFilters = parseFiltersString(otherFiltersString)

val request = new DescribeInstancesRequest()
.withFilters(runningInstancesFilter)
.withFilters(tagFilter)
.withFilters(otherFilters)
val allFilters: util.List[Filter] = (runningInstancesFilter :: tagFilter :: otherFilters).asJava

val request = new DescribeInstancesRequest().withFilters(allFilters) // withFilters is a set operation

import system.dispatcher

Expand Down

0 comments on commit 0582918

Please sign in to comment.