Skip to content

Commit

Permalink
fix: recreate channel on tier change
Browse files Browse the repository at this point in the history
OTT-7024
  • Loading branch information
thatsddr committed Jan 22, 2025
1 parent 9792ad3 commit 0133b06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions awsmt/resource_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"strings"
Expand Down Expand Up @@ -114,6 +116,9 @@ func (r *resourceChannel) Schema(_ context.Context, _ resource.SchemaRequest, re
stringvalidator.OneOf([]string{"BASIC", "STANDARD"}...),
},
Default: stringdefault.StaticString("BASIC"),
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
},
}
Expand Down
18 changes: 12 additions & 6 deletions awsmt/resource_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,23 @@ func TestAccChannelValuesNotFlickering(t *testing.T) {
})
}

func TestAccChannelResourceSTANDARD(t *testing.T) {
func TestAccChannelTierChange(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: standardTierChannel(),
Config: standardTierChannel("STANDARD"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.awsmt_channel.test", "tier", "STANDARD"),
),
},
{
Config: standardTierChannel("BASIC"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.awsmt_channel.test", "tier", "BASIC"),
),
},
},
})
}
Expand Down Expand Up @@ -408,8 +414,8 @@ func logConfigChannel(enable bool) string {
`, enable)
}

func standardTierChannel() string {
return `resource "awsmt_vod_source" "test" {
func standardTierChannel(t string) string {
return fmt.Sprintf(`resource "awsmt_vod_source" "test" {
http_package_configurations = [{
path = "/"
source_group = "default"
Expand Down Expand Up @@ -464,7 +470,7 @@ func standardTierChannel() string {
vod_source_name = awsmt_vod_source.test.name
}
policy = "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Sid\": \"AllowAnonymous\", \"Effect\": \"Allow\", \"Principal\": \"*\", \"Action\": \"mediatailor:GetManifest\", \"Resource\": \"arn:aws:mediatailor:eu-central-1:985600762523:channel/test\"}]}"
tier = "STANDARD"
tier = "%s"
tags = {"Environment": "dev"}
}
Expand All @@ -475,5 +481,5 @@ func standardTierChannel() string {
output "channel_out" {
value = data.awsmt_channel.test
}
`
`, t)
}

0 comments on commit 0133b06

Please sign in to comment.