Skip to content

Commit

Permalink
fix: change recreation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsddr committed May 20, 2022
1 parent 2e4ff60 commit fcef746
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions awsmt/resource_playback_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/mediatailor"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"time"
)
Expand Down Expand Up @@ -86,6 +87,9 @@ func resourcePlaybackConfiguration() *schema.Resource {
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
CustomizeDiff: customdiff.Sequence(
customdiff.ForceNewIfChange("name", func(ctx context.Context, old, new, meta interface{}) bool { return old.(string) != new.(string) }),
),
}
}

Expand All @@ -108,13 +112,6 @@ func resourcePlaybackConfigurationUpdate(ctx context.Context, d *schema.Resource
var diags diag.Diagnostics
client := m.(*mediatailor.MediaTailor)

if d.HasChange("name") {
oldValue, newValue := d.GetChange("name")
oldName := oldValue.(string)
deletePlaybackConfiguration(client, oldName)
d.SetId(newValue.(string))
}

if d.HasChange("tags") {
oldValue, newValue := d.GetChange("tags")
var removedTags []string
Expand Down

0 comments on commit fcef746

Please sign in to comment.