From 1abb0b19bfc0f259eea25bf6c391987631e63ba5 Mon Sep 17 00:00:00 2001 From: stack72 Date: Tue, 3 Nov 2015 23:57:51 +0000 Subject: [PATCH] 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 37662b201..1bcde095d 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 e63be73a8..d58f33ed7 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 499e13ba4..a5544c486 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