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.86k stars 9.21k forks source link

[Enhancement]: aws_ecr_images with filter #40025

Open sarasensible opened 3 weeks ago

sarasensible commented 3 weeks ago

Description

This cli command with filter https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecr/describe-images.html would be awesome to port to Terraform. Sometimes container tags are multi-purpose as in they have various architectures or OSes and you need to filter for a particular type of container along with the most recent. Could optionally provide most recent based on a query result, or the results from this could be fed into the regular aws_ecr_image data source to provide the most recent one of that particular tag. Would be nicer though to have it all from this one place, although I understand since the underlying api might not easily support that.

Affected Resource(s) and/or Data Source(s)

Potential Terraform Configuration

# Analogous to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami_ids in that it should take a regex/wildcard:

data "aws_ecr_images" "ubuntu" {
  repository_name = "my/service"

  filter {
    name   = "image_tag"
    values = ["ubuntu-*"]
  }
  filter {
    name   = "most_recent"
    values = true
  }
}

References

Describe Images AMI IDs

Would you like to implement a fix?

None

github-actions[bot] commented 3 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

sarasensible commented 3 weeks ago

Could be mitigated by https://github.com/hashicorp/terraform-provider-aws/pull/38783