Running the example configuration:
data "aws_ami" "eks-worker" {
filter {
name = "name"
values = ["amazon-eks-node-v*"]
}
most_recent = true
owners = ["9999999999"] # Amazon
}
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: 2018/09/26 10:44:02 [DEBUG] Reading AMI: {
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Filters: [{
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Name: "name",
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Values: ["amazon-eks-node-v*"]
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: }],
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Owners: ["9999999999"]
2018-09-26T10:44:02.722-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: }
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: 2018/09/26 10:44:02 [DEBUG] [aws-sdk-go] DEBUG: Request ec2/DescribeImages Details:
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: ---[ REQUEST POST-SIGN ]-----------------------------
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: POST / HTTP/1.1
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Host: ec2.us-west-2.amazonaws.com
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: User-Agent: aws-sdk-go/1.15.33 (go1.11; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.11.8
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Content-Length: 118
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Authorization: AWS4-HMAC-SHA256 Credential=HIDDEN
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Content-Type: application/x-www-form-urlencoded; charset=utf-8
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: X-Amz-Date: 20180926T174402Z
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: X-Amz-Security-Token: HIDDEN
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Accept-Encoding: gzip
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4:
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Action=DescribeImages&Filter.1.Name=name&Filter.1.Value.1=amazon-eks-node-v%2A&Owner.1=603124411859&Version=2016-11-15
2018-09-26T10:44:02.723-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: -----------------------------------------------------
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: 2018/09/26 10:44:03 [DEBUG] [aws-sdk-go] DEBUG: Response ec2/DescribeImages Details:
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: ---[ RESPONSE ]--------------------------------------
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: HTTP/1.1 200 OK
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Connection: close
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Content-Length: 219
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Content-Type: text/xml;charset=UTF-8
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Date: Wed, 26 Sep 2018 17:44:02 GMT
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: Server: AmazonEC2
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4:
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4:
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: -----------------------------------------------------
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: 2018/09/26 10:44:03 [DEBUG] [aws-sdk-go] <?xml version="1.0" encoding="UTF-8"?>
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: <DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: <requestId>992e841a-d18b-4255-b9e6-d8a0fd50c0b4</requestId>
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: <imagesSet/>
2018-09-26T10:44:03.023-0700 [DEBUG] plugin.terraform-provider-aws_v1.37.0_x4: </DescribeImagesResponse>
2018/09/26 10:44:03 [ERROR] root.zoml_eks_cluster: eval: *terraform.EvalReadDataApply, err: data.aws_ami.eks-worker: Your query returned no results. Please change your search criteria and try again.
2018/09/26 10:44:03 [ERROR] root.zoml_eks_cluster: eval: *terraform.EvalSequence, err: data.aws_ami.eks-worker: Your query returned no results. Please change your search criteria and try again.
2018/09/26 10:44:03 [TRACE] [walkRefresh] Exiting eval tree: module.zoml_eks_cluster.data.aws_ami.eks-worker
Running AWS CLI works just fine:
aws --profile blah ec2 describe-images --filters "Name=name,Values=amazon-eks-node-v*" --owner 99999999999
{
"Images": [
{
"VirtualizationType": "hvm",
"Description": "EKS Kubernetes Worker AMI with AmazonLinux2 image",
"Hypervisor": "xen",
"EnaSupport": true,
"SriovNetSupport": "simple",
"ImageId": "ami-08cab282f9979fc7a",
"State": "available",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": true,
"VolumeType": "gp2",
"VolumeSize": 20,
"SnapshotId": "snap-08f63251d1c8aefcc"
}
}
],
"Architecture": "x86_64",
"ImageLocation": "99999999999/amazon-eks-node-v23",
"RootDeviceType": "ebs",
"OwnerId": "99999999999",
"RootDeviceName": "/dev/xvda",
"CreationDate": "2018-08-20T23:25:53.000Z",
"Public": true,
"ImageType": "machine",
"Name": "amazon-eks-node-v23"
},
{
"VirtualizationType": "hvm",
"Description": "EKS Kubernetes Worker AMI with AmazonLinux2 image",
"Hypervisor": "xen",
"EnaSupport": true,
"SriovNetSupport": "simple",
"ImageId": "ami-0a54c984b9f908c81",
"State": "available",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Encrypted": false,
"DeleteOnTermination": true,
"VolumeType": "gp2",
"VolumeSize": 20,
"SnapshotId": "snap-0906f02f0068f2110"
}
}
],
"Architecture": "x86_64",
"ImageLocation": "99999999999/amazon-eks-node-v24",
"RootDeviceType": "ebs",
"OwnerId": "9999999999999",
"RootDeviceName": "/dev/xvda",
"CreationDate": "2018-09-12T22:21:11.000Z",
"Public": true,
"ImageType": "machine",
"Name": "amazon-eks-node-v24"
}
]
}
The problem seem to go away if i don't specify the account id, this woks fine:
data "aws_ami" "eks-worker" {
filter {
name = "name"
values = ["amazon-eks-node-v*"]
}
most_recent = true
}
I checked 10 times the account id is correct on my side.
Hi @apryiomka 👋 Sorry you are running into trouble here!
I was writing up a configuration to reproduce your issue and I realized that you were purposefully omitting the owners/OwnerId above, which seems odd unless you are trying to copy the AMI to your account first and trying to hide your own AWS account ID. The account ID in the EKS Getting Started Guide, 602401143452, is the source AWS account ID for the EKS images.
Can you confirm whether or not you are trying to copy the AMI to your account or if "602401143452" owner works?
Here is a working configuration, using the aws_ami data source configuration copied directly from the EKS Getting Started Guide:
terraform {
required_version = "0.11.8"
}
provider "aws" {
region = "us-west-2"
version = "1.38.0"
}
data "aws_ami" "eks-worker" {
filter {
name = "name"
values = ["amazon-eks-node-v*"]
}
most_recent = true
owners = ["602401143452"] # Amazon Account ID
}
output "ami_id" {
value = "${data.aws_ami.eks-worker.id}"
}
output "name" {
value = "${data.aws_ami.eks-worker.name}"
}
Output:
$ terraform init
...
$ terraform apply -auto-approve
data.aws_ami.eks-worker: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
ami_id = ami-0a54c984b9f908c81
name = amazon-eks-node-v24
Hope this helps.
Closing due to lack of response.
I am having the same issue like the one indicated above. The script was failing with no results found when the script contained 'owners' however when I removed the owners part it worked fine. I am not copying ami I just don't want hardcoded ami codes in my script.
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
Duplicate of: GH-1596
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
The problem seem to go away if i don't specify the account id, this woks fine:
I checked 10 times the account id is correct on my side.