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.63k stars 9.01k forks source link

Argument Reference - Filter - Data Source: aws_directory_service_directory #25120

Open marciogmorales opened 2 years ago

marciogmorales commented 2 years ago

Community Note

Description

When working with multiple AWS Directory Services, using Dependency Inversion becomes challenging because Filter doesn't allow to search by tag as argument references. It requires the use of a Module composition approach.

New or Affected Resource(s)

Potential Terraform Configuration


data "aws_directory_service_directory" "managed_ad" {
  filter {
    name   = "tag:Name"
    values = ["MyManagedAD01"]
  }
}

References

n2N8Z commented 1 year ago

The Potential Terraform Configuration should be without directory_id, because you don't need the filters if you already have the id.

data "aws_directory_service_directory" "managed_ad" {
  filter {
    name   = "tag:Name"
    values = ["MyManagedAD01"]
  }
}

But describe-directories has no filter parameter, and does not return tags, so terraform can't really provide the desired functionality.

sueastside commented 5 months ago

Current workaround seems a bit convoluted, as the datasource only takes the id, not the arn;

data "aws_resourcegroupstaggingapi_resources" "example" {
  resource_type_filters = ["fsx:file-system"]
  tag_filter {
    key    = "Name"
    values = ["fsx-example"]
  }
}

data "aws_fsx_windows_file_system" "example" {
  id = split("/", data.aws_resourcegroupstaggingapi_resources.example.resource_tag_mapping_list[0].resource_arn)[1]
}

output "fsx" {
  value = data.aws_fsx_windows_file_system.example
}
marciogmorales commented 5 months ago

@justinretzolk Do you have any update on this?

justinretzolk commented 5 months ago

Hey @marciogmorales 👋 Thanks for checking in on this one! I can't speak to when this will be prioritized just yet, so don't have much of an update, unfortunately. We base our prioritization on the count of :+1: reactions and a few other considerations (more information: prioritization guide).