Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data "aws_instances" not working in ap-sotheast-1 #17866

Closed
ghost opened this issue Mar 1, 2021 · 2 comments
Closed

data "aws_instances" not working in ap-sotheast-1 #17866

ghost opened this issue Mar 1, 2021 · 2 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@ghost
Copy link

ghost commented Mar 1, 2021

This issue was originally opened by @Teja1126 as hashicorp/terraform#27947. It was migrated here as a result of the provider split. The original body of the issue is below.


Hi there,

We have an issue with the terraform script which is working in us-west-1 same script is failing in ap-sotheast-1

Terraform Version

Terraform v0.14.0

  • provider registry.terraform.io/hashicorp/aws v3.22.0
  • provider registry.terraform.io/hashicorp/local v2.0.0
  • provider registry.terraform.io/hashicorp/null v3.0.0
  • provider registry.terraform.io/hashicorp/tls v3.0.0

Your version of Terraform is out of date! The latest version
is 0.14.7. You can update by downloading from https://www.terraform.io/downloads.html

Terraform Code

locals {
s-1 = "customevm-1"
s-2 = "customevm-2"
n-1 = "customevm-3"
}

data "aws_instances" "s-1" {

filter {
name = "tag:Name"
values = [local.s-1]
}
}

data "aws_instances" "s-2" {

filter {
name = "tag:Name"
values = [local.s-2]
}
}

data "aws_instances" "n-1" {

filter {
name = "tag:Name"
values = [local.n-1]
}
}

resource "local_file" "ec2_instances" {
content = <<EOT
n-1=${data.aws_instances.n-1.ids[0]}
s-1=${data.aws_instances.s-1.ids[0]}
s-2=${data.aws_instances.s-2.ids[0]}
EOT

filename = "../ec2_instances.txt"
}

Terraform Configuration Files

tfvars
access_key="xxxxxxxxxxxxxxx"
secret_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
region="ap-southeast-1"

Debug Output

Crash Output

terraform plan

Error: Your query returned no results. Please change your search criteria and try again.

Error: Your query returned no results. Please change your search criteria and try again.

Error: Your query returned no results. Please change your search criteria and try again.

Same code in other region

Terraform will perform the following actions:

terraform plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

  • create

Terraform will perform the following actions:

local_file.ec2_instances will be created
  • resource "local_file" "ec2_instances" {
    • content = <<-EOT
      s-1=i-05xxxxxxxxxxx46
      s-2=i-0axxxxxxxxxxx72
      n-1=i-09xxxxxxxxxxx80
      EOT
    • directory_permission = "0777"
    • file_permission = "0777"
    • filename = "../ec2_instances.txt"
    • id = (known after apply)
      }

Plan: 1 to add, 0 to change, 0 to destroy.

Expected Behavior

terraform plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:

  • create

Terraform will perform the following actions:

local_file.ec2_instances will be created

  • resource "local_file" "ec2_instances" {
    • content = <<-EOT
      s-1=i-05xxxxxxxxxxx46
      s-2=i-0axxxxxxxxxxx72
      n-1=i-09xxxxxxxxxxx80
      EOT
    • directory_permission = "0777"
    • file_permission = "0777"
    • filename = "../ec2_instances.txt"
    • id = (known after apply)
      }

Plan: 1 to add, 0 to change, 0 to destroy.

Actual Behavior

terraform plan

Error: Your query returned no results. Please change your search criteria and try again.

Error: Your query returned no results. Please change your search criteria and try again.

Error: Your query returned no results. Please change your search criteria and try again.

Steps to Reproduce

  1. make sure ec2 instances with those names.
  2. get the above file.
  3. add provider file
  4. terraform init
  5. terraform plan

Additional Context

References

@ghost ghost added the bug Addresses a defect in current functionality. label Mar 1, 2021
@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Mar 1, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 1, 2021
@bflad
Copy link
Contributor

bflad commented Mar 1, 2021

Hi @Teja1126 👋 Thank you for submitting this and sorry you ran into trouble with this data source. Plural data sources, such as aws_instances, do have some inconsistent implementations across them where some allow zero results without error while others do not. We are tracking these fixes across the provider in #17540, which is currently marked for the next major version release of the provider in case of unexpected behavior changes for configurations but may be completed sooner if there is enough demand. Please feel free to 👍 and subscribe to that issue for further updates.

@bflad bflad closed this as completed Mar 1, 2021
@ghost
Copy link
Author

ghost commented Mar 31, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 31, 2021
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

2 participants