Fix. Return correct AMI image when `most_recent` is set to `true`.

This commit resolves a regression introduced in #9033 that caused an
unfiltered image to be returned despite a search criteria being set
accordingly.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
This commit is contained in:
Krzysztof Wilczynski 2016-10-07 12:05:54 +01:00
parent 843db01d17
commit 664c788b26
No known key found for this signature in database
GPG Key ID: B89F6447B63419A6
1 changed files with 3 additions and 2 deletions

View File

@ -270,11 +270,12 @@ func dataSourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Your query returned more than one result. Please try a more " +
"specific search criteria, or set `most_recent` attribute to true.")
}
} else {
// Query returned single result.
image = filteredImages[0]
}
image = filteredImages[0]
log.Printf("[DEBUG] aws_ami - Single AMI found: %s", *image.ImageId)
return amiDescriptionAttributes(d, image)
}