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

Fix changing engine_version attempts to update resource class #5948

Merged
merged 1 commit into from
Sep 20, 2018
Merged

Fix changing engine_version attempts to update resource class #5948

merged 1 commit into from
Sep 20, 2018

Conversation

beny23
Copy link
Contributor

@beny23 beny23 commented Sep 20, 2018

Currently when changing a DMS instance, any change to the engine_version attempts to update the ReplicationInstanceClass

Fixes #0000

Changes proposed in this pull request:

  • Bugfix to ensure DMS engine_version can be updated.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSAvailabilityZones'

...

Currently when changing a DMS instance, any change to the `engine_version` attempts to update the `ReplicationInstanceClass`
@bflad bflad added bug Addresses a defect in current functionality. service/databasemigrationservice labels Sep 20, 2018
@bflad bflad added this to the v1.38.0 milestone Sep 20, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @beny23 👋 Thanks for submitting this!

I was able to write up an acceptance test to cover this behavior and prevent regressions in the future:

func TestAccAWSDmsReplicationInstance_EngineVersion(t *testing.T) {
	resourceName := "aws_dms_replication_instance.test"
	rName := acctest.RandomWithPrefix("tf-acc-test")

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: dmsReplicationInstanceDestroy,
		Steps: []resource.TestStep{
			{
				Config: testAccAWSDmsReplicationInstanceConfig_EngineVersion(rName, "2.4.2"),
				Check: resource.ComposeTestCheckFunc(
					checkDmsReplicationInstanceExists(resourceName),
					resource.TestCheckResourceAttr(resourceName, "engine_version", "2.4.2"),
				),
			},
			{
				ResourceName:            resourceName,
				ImportState:             true,
				ImportStateVerify:       true,
				ImportStateVerifyIgnore: []string{"apply_immediately"},
			},
			{
				Config: testAccAWSDmsReplicationInstanceConfig_EngineVersion(rName, "2.4.3"),
				Check: resource.ComposeTestCheckFunc(
					checkDmsReplicationInstanceExists(resourceName),
					resource.TestCheckResourceAttr(resourceName, "engine_version", "2.4.3"),
				),
			},
		},
	})
}

func testAccAWSDmsReplicationInstanceConfig_EngineVersion(rName, engineVersion string) string {
	return fmt.Sprintf(`
resource "aws_dms_replication_instance" "test" {
  apply_immediately          = true
  engine_version             = %q
  replication_instance_class = "dms.t2.micro"
  replication_instance_id    = %q
}
`, engineVersion, rName)
}

Running it before your code update:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSDmsReplicationInstance_EngineVersion'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDmsReplicationInstance_EngineVersion -timeout 120m
=== RUN   TestAccAWSDmsReplicationInstance_EngineVersion
--- FAIL: TestAccAWSDmsReplicationInstance_EngineVersion (440.26s)
    testing.go:527: Step 2 error: Error applying: 1 error occurred:
        	* aws_dms_replication_instance.test: 1 error occurred:
        	* aws_dms_replication_instance.test: InvalidParameterValueException: Invalid ReplicationInstance class:2.4.3
        	status code: 400, request id: 65419ced-bcf8-11e8-88cf-f15605cc1807




FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	441.017s

After your code update, it actually uncovered a new issue:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSDmsReplicationInstance_EngineVersion'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDmsReplicationInstance_EngineVersion -timeout 120m
=== RUN   TestAccAWSDmsReplicationInstance_EngineVersion
--- FAIL: TestAccAWSDmsReplicationInstance_EngineVersion (524.21s)
    testing.go:527: Step 2 error: Error applying: 1 error occurred:
        	* aws_dms_replication_instance.test: 1 error occurred:
        	* aws_dms_replication_instance.test: unexpected state 'upgrading', wanted target 'available'. last error: %!s(<nil>)




FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	524.973s

I added upgrading as an allowed pending state for ModifyReplicationInstance, which got everything passing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSDmsReplicationInstance_EngineVersion'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDmsReplicationInstance_EngineVersion -timeout 120m
=== RUN   TestAccAWSDmsReplicationInstance_EngineVersion
--- PASS: TestAccAWSDmsReplicationInstance_EngineVersion (603.15s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	603.961s

@bflad bflad merged commit 3255a35 into hashicorp:master Sep 20, 2018
bflad added a commit that referenced this pull request Sep 20, 2018
@beny23
Copy link
Contributor Author

beny23 commented Sep 20, 2018

@bflad thank you!!!

@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

This has been released in version 1.38.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants