Skip to content

Commit a44c867

Browse files
authored
Merge pull request #91 from spring-media/fix/OTT-7204
fix: recreate channel on tier change
2 parents 9792ad3 + 0133b06 commit a44c867

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

awsmt/resource_channel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework/path"
99
"github.com/hashicorp/terraform-plugin-framework/resource"
1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
11+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1112
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
13+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1214
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1315
"github.com/hashicorp/terraform-plugin-framework/types"
1416
"strings"
@@ -114,6 +116,9 @@ func (r *resourceChannel) Schema(_ context.Context, _ resource.SchemaRequest, re
114116
stringvalidator.OneOf([]string{"BASIC", "STANDARD"}...),
115117
},
116118
Default: stringdefault.StaticString("BASIC"),
119+
PlanModifiers: []planmodifier.String{
120+
stringplanmodifier.RequiresReplace(),
121+
},
117122
},
118123
},
119124
}

awsmt/resource_channel_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,23 @@ func TestAccChannelValuesNotFlickering(t *testing.T) {
221221
})
222222
}
223223

224-
func TestAccChannelResourceSTANDARD(t *testing.T) {
224+
func TestAccChannelTierChange(t *testing.T) {
225225
resource.Test(t, resource.TestCase{
226226
PreCheck: func() { testAccPreCheck(t) },
227227
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
228228
Steps: []resource.TestStep{
229229
{
230-
Config: standardTierChannel(),
230+
Config: standardTierChannel("STANDARD"),
231231
Check: resource.ComposeAggregateTestCheckFunc(
232232
resource.TestCheckResourceAttr("data.awsmt_channel.test", "tier", "STANDARD"),
233233
),
234234
},
235+
{
236+
Config: standardTierChannel("BASIC"),
237+
Check: resource.ComposeAggregateTestCheckFunc(
238+
resource.TestCheckResourceAttr("data.awsmt_channel.test", "tier", "BASIC"),
239+
),
240+
},
235241
},
236242
})
237243
}
@@ -408,8 +414,8 @@ func logConfigChannel(enable bool) string {
408414
`, enable)
409415
}
410416

411-
func standardTierChannel() string {
412-
return `resource "awsmt_vod_source" "test" {
417+
func standardTierChannel(t string) string {
418+
return fmt.Sprintf(`resource "awsmt_vod_source" "test" {
413419
http_package_configurations = [{
414420
path = "/"
415421
source_group = "default"
@@ -464,7 +470,7 @@ func standardTierChannel() string {
464470
vod_source_name = awsmt_vod_source.test.name
465471
}
466472
policy = "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Sid\": \"AllowAnonymous\", \"Effect\": \"Allow\", \"Principal\": \"*\", \"Action\": \"mediatailor:GetManifest\", \"Resource\": \"arn:aws:mediatailor:eu-central-1:985600762523:channel/test\"}]}"
467-
tier = "STANDARD"
473+
tier = "%s"
468474
tags = {"Environment": "dev"}
469475
}
470476
@@ -475,5 +481,5 @@ func standardTierChannel() string {
475481
output "channel_out" {
476482
value = data.awsmt_channel.test
477483
}
478-
`
484+
`, t)
479485
}

0 commit comments

Comments
 (0)