From 1abb0b19bfc0f259eea25bf6c391987631e63ba5 Mon Sep 17 00:00:00 2001 From: stack72 Date: Tue, 3 Nov 2015 23:57:51 +0000 Subject: [PATCH 1/3] Changing the db_instance resource to mark the engine_version as Optional --- .../providers/aws/resource_aws_db_instance.go | 2 +- .../aws/resource_aws_db_instance_test.go | 41 +++++++++++++++++++ .../providers/aws/r/db_instance.html.markdown | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 37662b201ff5..1bcde095d476 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -54,7 +54,7 @@ func resourceAwsDbInstance() *schema.Resource { "engine_version": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, }, "storage_encrypted": &schema.Schema{ diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index e63be73a828f..d58f33ed7d03 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -49,6 +49,25 @@ func TestAccAWSDBInstance_basic(t *testing.T) { }) } +func TestAccAWSDBInstance_withoutEngineVersion(t *testing.T) { + var v rds.DBInstance + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSDBInstanceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSDBInstanceConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v), + testAccCheckAWSDBInstanceAttributes(&v), + ), + }, + }, + }) +} + func TestAccAWSDBInstanceReplica(t *testing.T) { var s, r rds.DBInstance @@ -194,6 +213,28 @@ resource "aws_db_instance" "bar" { parameter_group_name = "default.mysql5.6" }`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) +var testAccAWSDBInstanceConfig_withoutEngineVersion = fmt.Sprintf(` +resource "aws_db_instance" "bar" { + identifier = "foobarbaz-test-terraform-%d" + + allocated_storage = 10 + engine = "MySQL" + instance_class = "db.t1.micro" + name = "baz" + password = "barbarbarbar" + username = "foo" + + + # Maintenance Window is stored in lower case in the API, though not strictly + # documented. Terraform will downcase this to match (as opposed to throw a + # validation error). + maintenance_window = "Fri:09:00-Fri:09:30" + + backup_retention_period = 0 + + parameter_group_name = "default.mysql5.6" +}`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) + func testAccReplicaInstanceConfig(val int) string { return fmt.Sprintf(` resource "aws_db_instance" "bar" { diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index 499e13ba40ce..a5544c486e68 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -36,7 +36,7 @@ The following arguments are supported: * `allocated_storage` - (Required) The allocated storage in gigabytes. * `engine` - (Required) The database engine to use. -* `engine_version` - (Required) The engine version to use. +* `engine_version` - (Optional) The engine version to use. * `identifier` - (Required) The name of the RDS instance * `instance_class` - (Required) The instance type of the RDS instance. * `storage_type` - (Optional) One of "standard" (magnetic), "gp2" (general From e3a66d092882cfa2066ca4b216aa1f815a4e6f9d Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Mon, 9 Nov 2015 22:23:55 +0000 Subject: [PATCH 2/3] Making engine_version be computed in the db_instance provider --- builtin/providers/aws/resource_aws_db_instance.go | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 1bcde095d476..e941a359ff83 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -55,6 +55,7 @@ func resourceAwsDbInstance() *schema.Resource { "engine_version": &schema.Schema{ Type: schema.TypeString, Optional: true, + Computed: true, }, "storage_encrypted": &schema.Schema{ From 6e21cd746e56ca2f52864cc0e7745daa655784d9 Mon Sep 17 00:00:00 2001 From: stack72 Date: Tue, 10 Nov 2015 17:35:12 +0000 Subject: [PATCH 3/3] Removing the AWS DBInstance Acceptance Test for withoutEngine as this is now part of the checkInstanceAttributes func --- .../aws/resource_aws_db_instance_test.go | 45 +------------------ 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index d58f33ed7d03..a2c2f69cad64 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -31,8 +31,6 @@ func TestAccAWSDBInstance_basic(t *testing.T) { "aws_db_instance.bar", "allocated_storage", "10"), resource.TestCheckResourceAttr( "aws_db_instance.bar", "engine", "mysql"), - resource.TestCheckResourceAttr( - "aws_db_instance.bar", "engine_version", "5.6.21"), resource.TestCheckResourceAttr( "aws_db_instance.bar", "license_model", "general-public-license"), resource.TestCheckResourceAttr( @@ -49,25 +47,6 @@ func TestAccAWSDBInstance_basic(t *testing.T) { }) } -func TestAccAWSDBInstance_withoutEngineVersion(t *testing.T) { - var v rds.DBInstance - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSDBInstanceDestroy, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccAWSDBInstanceConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v), - testAccCheckAWSDBInstanceAttributes(&v), - ), - }, - }, - }) -} - func TestAccAWSDBInstanceReplica(t *testing.T) { var s, r rds.DBInstance @@ -130,7 +109,7 @@ func testAccCheckAWSDBInstanceAttributes(v *rds.DBInstance) resource.TestCheckFu return fmt.Errorf("bad engine: %#v", *v.Engine) } - if *v.EngineVersion != "5.6.21" { + if *v.EngineVersion == "" { return fmt.Errorf("bad engine_version: %#v", *v.EngineVersion) } @@ -213,28 +192,6 @@ resource "aws_db_instance" "bar" { parameter_group_name = "default.mysql5.6" }`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) -var testAccAWSDBInstanceConfig_withoutEngineVersion = fmt.Sprintf(` -resource "aws_db_instance" "bar" { - identifier = "foobarbaz-test-terraform-%d" - - allocated_storage = 10 - engine = "MySQL" - instance_class = "db.t1.micro" - name = "baz" - password = "barbarbarbar" - username = "foo" - - - # Maintenance Window is stored in lower case in the API, though not strictly - # documented. Terraform will downcase this to match (as opposed to throw a - # validation error). - maintenance_window = "Fri:09:00-Fri:09:30" - - backup_retention_period = 0 - - parameter_group_name = "default.mysql5.6" -}`, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) - func testAccReplicaInstanceConfig(val int) string { return fmt.Sprintf(` resource "aws_db_instance" "bar" {