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

Use track_latest attribute for the aws_ecs_task_definition resource at service module #169

Closed
ivan-sukhomlyn opened this issue Feb 16, 2024 · 3 comments

Comments

@ivan-sukhomlyn
Copy link
Contributor

Is your request related to a new offering from AWS?

The track_latest attribute for the aws_ecs_task_definition resource released in in v5.37.0 of the Terraform AWS Provider

Related PR - hashicorp/terraform-provider-aws#30154

Is your request related to a problem?

Simplify the service module source code and pass sorting of ECS Taks Definition revisions to the Terraform provider.

Describe the solution you'd like.

Use the track_latest = true argument at the aws_ecs_task_definition instead of a custom implementation

# This allows us to query both the existing as well as Terraform's state and get
# and get the max version of either source, useful for when external resources
# update the container definition
max_task_def_revision = local.create_task_definition ? max(aws_ecs_task_definition.this[0].revision, data.aws_ecs_task_definition.this[0].revision) : 0
task_definition = local.create_task_definition ? "${aws_ecs_task_definition.this[0].family}:${local.max_task_def_revision}" : var.task_definition_arn
}
# This allows us to query both the existing as well as Terraform's state and get
# and get the max version of either source, useful for when external resources
# update the container definition
data "aws_ecs_task_definition" "this" {
count = local.create_task_definition ? 1 : 0
task_definition = aws_ecs_task_definition.this[0].family
depends_on = [
# Needs to exist first on first deployment
aws_ecs_task_definition.this
]
}

More Details

An appropriate GH issue - hashicorp/terraform-provider-aws#20121

@ivan-sukhomlyn
Copy link
Contributor Author

ivan-sukhomlyn commented Feb 16, 2024

@antonbabenko @bryantbiggs I can make a PR to the wip/v6 branch as it requires a bump of the AWS provider version to >= 5.37 if you are ok with that activity.
Thanks!

@bryantbiggs
Copy link
Member

yes please do - closing this issue though since its a duplicate of #164

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants