From 4d73f346eba5bee367d0fa2015db46f99eec1f22 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 10 Apr 2020 14:17:00 +0300 Subject: [PATCH] engine version is updatable --- aws/resource_aws_mq_broker.go | 4 +-- aws/resource_aws_mq_broker_test.go | 54 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_mq_broker.go b/aws/resource_aws_mq_broker.go index 00ef70f6f4f..b7c34b4fa69 100644 --- a/aws/resource_aws_mq_broker.go +++ b/aws/resource_aws_mq_broker.go @@ -98,7 +98,6 @@ func resourceAwsMqBroker() *schema.Resource { "engine_version": { Type: schema.TypeString, Required: true, - ForceNew: true, }, "host_instance_type": { Type: schema.TypeString, @@ -402,11 +401,12 @@ func resourceAwsMqBrokerUpdate(d *schema.ResourceData, meta interface{}) error { } } - if d.HasChange("configuration") || d.HasChange("logs") { + if d.HasChange("configuration") || d.HasChange("logs") || d.HasChange("engine_version") { _, err := conn.UpdateBroker(&mq.UpdateBrokerRequest{ BrokerId: aws.String(d.Id()), Configuration: expandMqConfigurationId(d.Get("configuration").([]interface{})), Logs: expandMqLogs(d.Get("logs").([]interface{})), + EngineVersion: aws.String(d.Get("engine_version").(string)), }) if err != nil { return fmt.Errorf("error updating MQ Broker (%s) configuration: %s", d.Id(), err) diff --git a/aws/resource_aws_mq_broker_test.go b/aws/resource_aws_mq_broker_test.go index 0554e7e025e..fbac0f65848 100644 --- a/aws/resource_aws_mq_broker_test.go +++ b/aws/resource_aws_mq_broker_test.go @@ -706,6 +706,34 @@ func TestAccAWSMqBroker_updateSecurityGroup(t *testing.T) { }) } +func TestAccAWSMqBroker_updateEngineVersion(t *testing.T) { + sgName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5)) + brokerName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5)) + resourceName := "aws_mq_broker.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSMq(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAwsMqBrokerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMqBrokerConfig(sgName, brokerName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsMqBrokerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.0"), + ), + }, + { + Config: testAccMqBrokerEngineVersionUpdateConfig(sgName, brokerName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsMqBrokerExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "engine_version", "5.15.9"), + ), + }, + }, + }) +} + func testAccCheckAwsMqBrokerDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).mqconn @@ -784,6 +812,32 @@ resource "aws_mq_broker" "test" { `, sgName, brokerName) } +func testAccMqBrokerEngineVersionUpdateConfig(sgName, brokerName string) string { + return fmt.Sprintf(` +resource "aws_security_group" "test" { + name = "%s" +} + +resource "aws_mq_broker" "test" { + broker_name = "%s" + apply_immediately = true + engine_type = "ActiveMQ" + engine_version = "5.15.9" + host_instance_type = "mq.t2.micro" + security_groups = ["${aws_security_group.test.id}"] + + logs { + general = true + } + + user { + username = "Test" + password = "TestTest1234" + } +} +`, sgName, brokerName) +} + func testAccMqBrokerConfig_allFieldsDefaultVpc(sgName, cfgName, cfgBody, brokerName string) string { return fmt.Sprintf(` resource "aws_security_group" "mq1" {