diff --git a/aws/resource_aws_rds_cluster.go b/aws/resource_aws_rds_cluster.go index fe22f0959e5..cd451b2d7c4 100644 --- a/aws/resource_aws_rds_cluster.go +++ b/aws/resource_aws_rds_cluster.go @@ -96,9 +96,18 @@ func resourceAwsRDSCluster() *schema.Resource { }, "engine": { + Type: schema.TypeString, + Optional: true, + Default: "aurora", + ForceNew: true, + ValidateFunc: validateRdsEngine, + }, + + "engine_version": { Type: schema.TypeString, Optional: true, - Default: "aurora", + ForceNew: true, + Computed: true, }, "storage_encrypted": { @@ -371,6 +380,10 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error createOpts.DBClusterParameterGroupName = aws.String(attr.(string)) } + if attr, ok := d.GetOk("engine_version"); ok { + createOpts.EngineVersion = aws.String(attr.(string)) + } + if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 { createOpts.VpcSecurityGroupIds = expandStringList(attr.List()) } @@ -560,6 +573,7 @@ func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error { d.Set("db_cluster_parameter_group_name", dbc.DBClusterParameterGroup) d.Set("endpoint", dbc.Endpoint) d.Set("engine", dbc.Engine) + d.Set("engine_version", dbc.EngineVersion) d.Set("master_username", dbc.MasterUsername) d.Set("port", dbc.Port) d.Set("storage_encrypted", dbc.StorageEncrypted) diff --git a/aws/resource_aws_rds_cluster_instance.go b/aws/resource_aws_rds_cluster_instance.go index ef66b10de9c..a3321f33316 100644 --- a/aws/resource_aws_rds_cluster_instance.go +++ b/aws/resource_aws_rds_cluster_instance.go @@ -84,6 +84,21 @@ func resourceAwsRDSClusterInstance() *schema.Resource { Required: true, }, + "engine": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "aurora", + ValidateFunc: validateRdsEngine, + }, + + "engine_version": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + }, + "db_parameter_group_name": { Type: schema.TypeString, Optional: true, @@ -176,7 +191,7 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{ createOpts := &rds.CreateDBInstanceInput{ DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)), - Engine: aws.String("aurora"), + Engine: aws.String(d.Get("engine").(string)), PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)), PromotionTier: aws.Int64(int64(d.Get("promotion_tier").(int))), AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)), @@ -201,6 +216,10 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{ createOpts.DBSubnetGroupName = aws.String(attr.(string)) } + if attr, ok := d.GetOk("engine_version"); ok { + createOpts.EngineVersion = aws.String(attr.(string)) + } + if attr, ok := d.GetOk("monitoring_role_arn"); ok { createOpts.MonitoringRoleArn = aws.String(attr.(string)) } @@ -292,6 +311,8 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{}) d.Set("publicly_accessible", db.PubliclyAccessible) d.Set("cluster_identifier", db.DBClusterIdentifier) + d.Set("engine", db.Engine) + d.Set("engine_version", db.EngineVersion) d.Set("instance_class", db.DBInstanceClass) d.Set("identifier", db.DBInstanceIdentifier) d.Set("dbi_resource_id", db.DbiResourceId) diff --git a/aws/resource_aws_rds_cluster_instance_test.go b/aws/resource_aws_rds_cluster_instance_test.go index 443a869e16f..72e49cd1728 100644 --- a/aws/resource_aws_rds_cluster_instance_test.go +++ b/aws/resource_aws_rds_cluster_instance_test.go @@ -34,6 +34,8 @@ func TestAccAWSRDSClusterInstance_basic(t *testing.T) { resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "preferred_backup_window"), resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "dbi_resource_id"), resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "availability_zone"), + resource.TestCheckResourceAttrSet("aws_rds_cluster_instance.cluster_instances", "engine_version"), + resource.TestCheckResourceAttr("aws_rds_cluster_instance.cluster_instances", "engine", "aurora"), ), }, { diff --git a/aws/resource_aws_rds_cluster_test.go b/aws/resource_aws_rds_cluster_test.go index 1f26952e0f0..51da8845220 100644 --- a/aws/resource_aws_rds_cluster_test.go +++ b/aws/resource_aws_rds_cluster_test.go @@ -36,6 +36,10 @@ func TestAccAWSRDSCluster_basic(t *testing.T) { "aws_rds_cluster.default", "reader_endpoint"), resource.TestCheckResourceAttrSet( "aws_rds_cluster.default", "cluster_resource_id"), + resource.TestCheckResourceAttr( + "aws_rds_cluster.default", "engine", "aurora"), + resource.TestCheckResourceAttrSet( + "aws_rds_cluster.default", "engine_version"), ), }, }, diff --git a/aws/validators.go b/aws/validators.go index bc99d79226e..93b7f80b6bd 100644 --- a/aws/validators.go +++ b/aws/validators.go @@ -51,6 +51,22 @@ func validateRdsIdentifierPrefix(v interface{}, k string) (ws []string, errors [ return } +func validateRdsEngine(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + + validTypes := map[string]bool{ + "aurora": true, + "aurora-postgresql": true, + } + + if _, ok := validTypes[value]; !ok { + errors = append(errors, fmt.Errorf( + "%q contains an invalid engine type %q. Valid types are either %q or %q.", + k, value, "aurora", "aurora-postgresql")) + } + return +} + func validateElastiCacheClusterId(v interface{}, k string) (ws []string, errors []error) { value := v.(string) if (len(value) < 1) || (len(value) > 20) { diff --git a/website/docs/r/rds_cluster.html.markdown b/website/docs/r/rds_cluster.html.markdown index 934ba1957e6..a984258b362 100644 --- a/website/docs/r/rds_cluster.html.markdown +++ b/website/docs/r/rds_cluster.html.markdown @@ -86,6 +86,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per * `iam_roles` - (Optional) A List of ARNs for the IAM roles to associate to the RDS Cluster. * `iam_database_authentication_enabled` - (Optional) Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. * `engine` - (Optional) The name of the database engine to be used for this DB cluster. Defaults to `aurora`. +* `engine_version` - (Optional) The database engine version. ## Attributes Reference diff --git a/website/docs/r/rds_cluster_instance.html.markdown b/website/docs/r/rds_cluster_instance.html.markdown index 5df3b906ab6..5a800e0ac6a 100644 --- a/website/docs/r/rds_cluster_instance.html.markdown +++ b/website/docs/r/rds_cluster_instance.html.markdown @@ -50,6 +50,8 @@ The following arguments are supported: * `identifier` - (Optional, Forces new resource) The indentifier for the RDS instance, if omitted, Terraform will assign a random, unique identifier. * `identifier_prefix` - (Optional, Forces new resource) Creates a unique identifier beginning with the specified prefix. Conflicts with `identifer`. * `cluster_identifier` - (Required) The identifier of the [`aws_rds_cluster`](/docs/providers/aws/r/rds_cluster.html) in which to launch this instance. +* `engine` - (Optional) The name of the database engine to be used for the RDS instance. Defaults to `aurora`. +* `engine_version` - (Optional) The database engine version. * `instance_class` - (Required) The instance class to use. For details on CPU and memory, see [Scaling Aurora DB Instances][4]. Aurora currently supports the below instance classes.