Skip to content

Commit 1dff78f

Browse files
committed
fix(ecs): Audit daemon task definition files and remove data sources
1 parent 722f4c8 commit 1dff78f

19 files changed

Lines changed: 266 additions & 1654 deletions

.changelog/47562.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ aws_ecs_daemon
66
aws_ecs_daemon_task_definition
77
```
88

9-
```release-note:new-data-source
10-
aws_ecs_daemon
11-
```
12-
13-
```release-note:new-data-source
14-
aws_ecs_daemons
15-
```
16-
17-
```release-note:new-data-source
18-
aws_ecs_daemon_task_definition
19-
```
20-
21-
```release-note:new-data-source
22-
aws_ecs_daemon_task_definitions
23-
```
24-
259
```release-note:new-list-resource
2610
aws_ecs_daemon
2711
```

internal/service/ecs/daemon.go

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
2424
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
2525
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
26-
"github.com/hashicorp/terraform-plugin-framework/types"
2726
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
28-
sdkid "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
27+
"github.com/hashicorp/terraform-plugin-framework/types"
2928
sdkretry "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
29+
"github.com/hashicorp/terraform-provider-aws/internal/create"
3030
"github.com/hashicorp/terraform-provider-aws/internal/enum"
3131
"github.com/hashicorp/terraform-provider-aws/internal/errs"
3232
"github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag"
@@ -180,7 +180,7 @@ func (r *daemonResource) Create(ctx context.Context, request resource.CreateRequ
180180
}
181181

182182
// Fields AutoFlex can't handle
183-
input.ClientToken = aws.String(sdkid.UniqueId())
183+
input.ClientToken = aws.String(create.UniqueId(ctx))
184184
input.Tags = getTagsIn(ctx)
185185

186186
// Write-only fields — read from config
@@ -375,7 +375,7 @@ func daemonNameFromARN(arn string) types.String {
375375
// provider ARNs from a DaemonRevision and DaemonRevisionDetail. DaemonTaskDefinitionArn is only
376376
// set when the model's value is null (e.g., during import) to avoid overwriting
377377
// the plan value with potentially stale revision data during Create/Update.
378-
func flattenDaemonRevision(ctx context.Context, revision *awstypes.DaemonRevision, revisionDetail awstypes.DaemonRevisionDetail, model *daemonResourceModel) {
378+
func flattenDaemonRevision(ctx context.Context, revision *awstypes.DaemonRevision, revisionDetail awstypes.DaemonRevisionDetail, model *daemonResourceModel) { // nosemgrep:ci.semgrep.framework.manual-flattener-functions
379379
if model.DaemonTaskDefinitionArn.IsNull() {
380380
model.DaemonTaskDefinitionArn = types.StringPointerValue(revision.DaemonTaskDefinitionArn)
381381
}
@@ -394,7 +394,7 @@ func flattenDaemonRevision(ctx context.Context, revision *awstypes.DaemonRevisio
394394
// flattenDaemonCurrentRevision fetches the current revision for a daemon and
395395
// flattens its fields into the model. This is shared across Create, Read,
396396
// Update, and the list resource.
397-
func flattenDaemonCurrentRevision(ctx context.Context, conn *ecs.Client, daemon *awstypes.DaemonDetail, diags *diag.Diagnostics, model *daemonResourceModel) {
397+
func flattenDaemonCurrentRevision(ctx context.Context, conn *ecs.Client, daemon *awstypes.DaemonDetail, diags *diag.Diagnostics, model *daemonResourceModel) { // nosemgrep:ci.semgrep.framework.manual-flattener-functions
398398
if len(daemon.CurrentRevisions) == 0 || daemon.CurrentRevisions[0].Arn == nil {
399399
return
400400
}
@@ -436,7 +436,7 @@ type alarmConfigurationModel struct {
436436

437437
// expandDaemonWriteOnlyFields reads write-only fields from the Terraform config.
438438
// These fields are not returned by the API, so they must always be read from config.
439-
func expandDaemonWriteOnlyFields(ctx context.Context, cfg tfsdk.Config, diags *diag.Diagnostics) (enableManagedTags, enableExecCmd types.Bool) {
439+
func expandDaemonWriteOnlyFields(ctx context.Context, cfg tfsdk.Config, diags *diag.Diagnostics) (enableManagedTags, enableExecCmd types.Bool) { // nosemgrep:ci.semgrep.framework.manual-expander-functions
440440
var data daemonResourceModel
441441
diags.Append(cfg.Get(ctx, &data)...)
442442
if diags.HasError() {
@@ -479,24 +479,6 @@ func findDaemonByARN(ctx context.Context, conn *ecs.Client, arn string) (*awstyp
479479
return output.Daemon, nil
480480
}
481481

482-
func findDaemons(ctx context.Context, conn *ecs.Client, input *ecs.ListDaemonsInput) ([]awstypes.DaemonSummary, error) {
483-
var result []awstypes.DaemonSummary
484-
485-
err := listDaemonsPages(ctx, conn, input, func(page *ecs.ListDaemonsOutput, lastPage bool) bool {
486-
if page == nil {
487-
return !lastPage
488-
}
489-
result = append(result, page.DaemonSummariesList...)
490-
return !lastPage
491-
})
492-
493-
if err != nil {
494-
return nil, err
495-
}
496-
497-
return result, nil
498-
}
499-
500482
func statusDaemon(ctx context.Context, conn *ecs.Client, arn string) sdkretry.StateRefreshFunc {
501483
return func() (any, string, error) {
502484
output, err := findDaemonByARN(ctx, conn, arn)

internal/service/ecs/daemon_data_source.go

Lines changed: 0 additions & 123 deletions
This file was deleted.

internal/service/ecs/daemon_data_source_test.go

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)