Hope you guys can help with this issue.
Using OSX Yosemite - Terraform 0.7.3 - region eu-west-1
I have this configured in my
site.tf test file to define the AMI I want to use for the build - as below :
provider "aws" {
region = "eu-west-1"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-instance/ubuntu-xenial-16.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["paravirtual"]
}
filter {
name = "image-id"
values = ["ami-280b715b"]
}
owners = ["099720109477"] # Canonical
}
I have looked at the AWS site below that shows the filters we can use in this data declaration
Now according to the Canonical AMI available site , there are four potential AMI's I can use, one of which supports paravirtual:
Here is the link:
The Ami I want is the one I have shown above - so I can run it with a m1.small - however type , I get the following error:
$terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.
data.aws_ami.ubuntu: Refreshing state...
Error refreshing state: 1 error(s) occurred:
* data.aws_ami.ubuntu: Your query returned no results. Please change your filters and try again.
For information - if I add the Ami definition directly into the aws_instance resource definition as below , it works fine:
resource "aws_instance" "rtorrent" {
#ami = "${data.aws_ami.ubuntu.id}"
ami = "ami-280b715b"
instance_type = "m1.small"
tags {
Name = "test"
}
key_name = "my-key-name"
vpc_security_group_ids = ["sg-1234567"]
subnet_id = "subnet-1234567"
}
Also if I change the instance_type to m3.medium, change the virtualisation_type to "hvm", and exclude the Ami image_id filter - it also works. That is because it finds one of the other images which supports those parameters , and it all works.
However , this is for testing , and I only want to use a m1.small.
Any thoughts on why the filtering is not working or if there are other settings I can be trying - all would be gratefully received, as Google has produced no answers to this one as yet.
Thanks in advance
Nick