in src/main/scala/com/gu/ssm/aws/EC2.scala [25:38]
def resolveByTags(tagValues: List[String], client: AmazonEC2Async)(implicit ec: ExecutionContext): Attempt[List[Instance]] = {
val allTags = tagValues ++ tagValues.map(_.toUpperCase) ++ tagValues.map(_.toLowerCase)
// if user has provided fewer than 3 tags then assume order app,stage,stack
val tagOrder = List("App", "Stage", "Stack")
val filters = new Filter("instance-state-name", List("running").asJava) ::
tagOrder.take(tagValues.length).map(makeFilter(_, allTags))
val request = new DescribeInstancesRequest()
.withFilters(
filters: _*
)
handleAWSErrs(awsToScala(client.describeInstancesAsync)(request).map(extractInstances))
}