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

r/aws_ecs_task_definition: add track_latest attribute #30154

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/30154.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ecs_task_definition: add track_latest attribute
```
13 changes: 12 additions & 1 deletion internal/service/ecs/task_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ func ResourceTaskDefinition() *schema.Resource {
ForceNew: true,
ValidateFunc: verify.ValidARN,
},
"track_latest": {
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"volume": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -562,8 +567,14 @@ func resourceTaskDefinitionRead(ctx context.Context, d *schema.ResourceData, met
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).ECSConn(ctx)

trackedTaskDefinition := aws.String(d.Get("arn").(string))
if v, ok := d.GetOk("track_latest"); ok && v.(bool) {
log.Printf("[DEBUG] Tracking latest ECS Task Definition")
trackedTaskDefinition = aws.String(d.Get("family").(string))
}

input := ecs.DescribeTaskDefinitionInput{
TaskDefinition: aws.String(d.Get("arn").(string)),
TaskDefinition: trackedTaskDefinition,
Include: []*string{aws.String(ecs.TaskDefinitionFieldTags)},
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ecs_task_definition.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ The following arguments are optional:
* `skip_destroy` - (Optional) Whether to retain the old revision when the resource is destroyed or replacement is necessary. Default is `false`.
* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `task_role_arn` - (Optional) ARN of IAM role that allows your Amazon ECS container task to make calls to other AWS services.
* `track_latest` - (Optional) Whether should track latest task definition or the one created with the resource. Default is `false`.
* `volume` - (Optional) Configuration block for [volumes](#volume) that containers in your task may use. Detailed below.

### volume
Expand Down
Loading