From 664c788b2655964c8a987be7336e3680b9f95edf Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Fri, 7 Oct 2016 12:05:54 +0100 Subject: [PATCH] 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 --- builtin/providers/aws/data_source_aws_ami.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/data_source_aws_ami.go b/builtin/providers/aws/data_source_aws_ami.go index 778d3a2efe3c..ff6200a2c112 100644 --- a/builtin/providers/aws/data_source_aws_ami.go +++ b/builtin/providers/aws/data_source_aws_ami.go @@ -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) }