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

aws_ecs_task_definition_data_source arn attribute #21856

Merged
Merged
Show file tree
Hide file tree
Changes from all 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/21856.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
data-source/aws_ecs_task_definition: Add `arn` attribute.
```
5 changes: 5 additions & 0 deletions internal/service/ecs/task_definition_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func DataSourceTaskDefinition() *schema.Resource {
Required: true,
},
// Computed values.
"arn": {
Type: schema.TypeString,
Computed: true,
},
"family": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -64,6 +68,7 @@ func dataSourceTaskDefinitionRead(d *schema.ResourceData, meta interface{}) erro
taskDefinition := desc.TaskDefinition

d.SetId(aws.StringValue(taskDefinition.TaskDefinitionArn))
d.Set("arn", taskDefinition.TaskDefinitionArn)
d.Set("family", taskDefinition.Family)
d.Set("network_mode", taskDefinition.NetworkMode)
d.Set("revision", taskDefinition.Revision)
Expand Down
1 change: 1 addition & 0 deletions internal/service/ecs/task_definition_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestAccECSTaskDefinitionDataSource_ecsTaskDefinition(t *testing.T) {
{
Config: testAccCheckTaskDefinitionDataSourceConfig(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(resourceName, "arn", "aws_ecs_task_definition.mongo", "arn"),
resource.TestCheckResourceAttr(resourceName, "family", rName),
resource.TestCheckResourceAttr(resourceName, "network_mode", "bridge"),
resource.TestMatchResourceAttr(resourceName, "revision", regexp.MustCompile("^[1-9][0-9]*$")),
Expand Down
3 changes: 2 additions & 1 deletion website/docs/d/ecs_task_definition.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "aws_ecs_service" "mongo" {
desired_count = 2

# Track the latest ACTIVE revision
task_definition = "${aws_ecs_task_definition.mongo.family}:${max(aws_ecs_task_definition.mongo.revision, data.aws_ecs_task_definition.mongo.revision)}"
task_definition = aws_ecs_task_definition.mongo.arn
}
```

Expand All @@ -65,6 +65,7 @@ The following arguments are supported:

In addition to all arguments above, the following attributes are exported:

* `arn` - The ARN of the task definition
* `family` - The family of this task definition
* `network_mode` - The Docker networking mode to use for the containers in this task.
* `revision` - The revision of this task definition
Expand Down