Skip to content
Draft
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
23 changes: 21 additions & 2 deletions cloudamqp/resource_cloudamqp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,19 @@ func resourceInstance() *schema.Resource {
},
CustomizeDiff: customdiff.All(
customdiff.ForceNewIfChange("plan", func(ctx context.Context, old, new, meta any) bool {
// Recreate instance if changing plan type (from dedicated to shared or vice versa)
// Going between RabbitMQ shared and dedicated plans requires resource replacement
oldPlanType := isSharedPlan(old.(string))
newPlanType := isSharedPlan(new.(string))
return !(oldPlanType == newPlanType)

isOldLavinmqSharedPlan := isLavinmqSharedPlan(old.(string))
isNewSharedPlan := isSharedPlan(new.(string))

// We allow moving Lavin Shared to Lavin dedicated, but not reverse
if isOldLavinmqSharedPlan && !isNewSharedPlan {
return false
} else {
return !(oldPlanType == newPlanType)
}
}),
customdiff.ValidateChange("plan", func(ctx context.Context, old, new, meta any) error {
if old == new {
Expand Down Expand Up @@ -347,6 +356,16 @@ func isSharedPlan(plan string) bool {
return false
}

func isLavinmqSharedPlan(plan string) bool {
switch plan {
case
"lemming",
"ermine":
return true
}
return false
}

func isLegacyPlan(plan string) bool {
switch plan {
case
Expand Down