hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.19k forks source link

data "aws_ebs_snapshot" doesnot filter out snapshot if provides 2 tags #38880

Closed Nida1998 closed 3 months ago

Nida1998 commented 3 months ago

Description

I am trying to pick snapshot id via data resource terraform, but unable to do so because of 2 tags provided.

Error: Your query returned no results. Please change your search criteria and try again. │ │ with module.CIM.data.aws_ebs_snapshot.web01_snapshot_sdba, │ on modules\CIM\main.tf line 17, in data "aws_ebs_snapshot" "web01_snapshot_sdba": │ 17: data "aws_ebs_snapshot" "web01_snapshot_sdba" {


Terraform script below:

data "aws_ebs_snapshot" "web01_snapshot_xvda" { most_recent = true owners = ["self"]

filter { name = "tag:DeviceName" values = ["dev/xvda"] }

filter { name = "tag:Name" values = ["prod-qa-cim-web-01"] } }

any work around will be highly appreciated. Manually putting snahpshot id is not possible. Need to pick latest, NMane + DeviceName

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

stefanfreitag commented 3 months ago

Hi @Nida1998,

thanks for bringing this to our attention. Could you please provide more details on the issue? We would like to understand what version of Terraform and the Terraform AWS provider are in use.

I took your code snippet and did a quick test using provider version 5.62.0 and Terraform v1.9.3:

data "aws_ebs_snapshot" "web01_snapshot_xvda" {
  most_recent = true
  owners      = ["self"]

  filter {
    name   = "tag:DeviceName"
    values = ["dev/xvdb"]
  }
  filter {
    name   = "tag:Name"
    values = ["server"]
  }
}

On the EBS snapshots I ensured that the tags are existing (verified this via management console). Then I executed a terraform plan

❯ terraform plan
data.aws_ebs_snapshot.web01_snapshot_xvda: Reading...
data.aws_ebs_snapshot.web01_snapshot_xvda: Read complete after 0s [id=snap-09c0028a8a37091f1]

No changes. Your infrastructure matches the configuration

This means, that two filters seems to be supported by the provider. I will review the relevant code later.

Could you please check if the tags are attached to the snapshots and provide the missing information on the versions? Thanks!

Nida1998 commented 3 months ago

Hi @stefanfreitag

I upgraded the terraform version to v1.9.4 and I am able to pick snapshot id based on 2 filters(tags). Much appreciated!

Kind Regards, Nida

github-actions[bot] commented 3 months ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 2 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.