Skip to content

Commit

Permalink
engine version is updatable
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Apr 10, 2020
1 parent 32b0486 commit 4d73f34
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws/resource_aws_mq_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func resourceAwsMqBroker() *schema.Resource {
"engine_version": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"host_instance_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -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)
Expand Down
54 changes: 54 additions & 0 deletions aws/resource_aws_mq_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 4d73f34

Please sign in to comment.