Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mq_broker: don't recreate when auto_minor_version_upgrade and host_instance_type changed #20661

Merged
merged 17 commits into from
Feb 8, 2022
Merged
22 changes: 20 additions & 2 deletions internal/service/mq/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func ResourceBroker() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},
"broker_name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -127,7 +126,6 @@ func ResourceBroker() *schema.Resource {
"host_instance_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"instances": {
Type: schema.TypeList,
Expand Down Expand Up @@ -559,6 +557,26 @@ func resourceBrokerUpdate(d *schema.ResourceData, meta interface{}) error {
}
}

if d.HasChange("host_instance_type") {
_, err := conn.UpdateBroker(&mq.UpdateBrokerRequest{
BrokerId: aws.String(d.Id()),
HostInstanceType: aws.String(d.Get("host_instance_type").(string)),
})
if err != nil {
return fmt.Errorf("error updating MQ Broker (%s) host instance type: %w", d.Id(), err)
}
}

if d.HasChange("auto_minor_version_upgrade") {
_, err := conn.UpdateBroker(&mq.UpdateBrokerRequest{
BrokerId: aws.String(d.Id()),
AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)),
})
if err != nil {
return fmt.Errorf("error updating MQ Broker (%s) auto minor version upgrade: %w", d.Id(), err)
}
}

if d.HasChange("tags_all") {
o, n := d.GetChange("tags_all")

Expand Down
4 changes: 4 additions & 0 deletions internal/service/mq/broker_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
)

func TestAccMQBrokerDataSource_basic(t *testing.T) {
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_mq_broker.test"

Expand Down
Loading