-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Allow RDS Cluster / Cluster instance to specify the engine #1591
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,9 +96,18 @@ func resourceAwsRDSCluster() *schema.Resource { | |
}, | ||
|
||
"engine": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "aurora", | ||
ForceNew: true, | ||
ValidateFunc: validateRdsEngine, | ||
}, | ||
|
||
"engine_version": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also read the engine version around line 575 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, missed that one. |
||
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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also read the engine_version here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will fix it too |
||
d.Set("engine_version", db.EngineVersion) | ||
d.Set("instance_class", db.DBInstanceClass) | ||
d.Set("identifier", db.DBInstanceIdentifier) | ||
d.Set("dbi_resource_id", db.DbiResourceId) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should validate the engine value, as we would need to update the code each time a new engine is available. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid point however, amazon introduced aurora for MySQL in 2014 and added PostgreSQL in 2017. Don't have insights into their product plans but so far if they keep adding one every 3 years updating code won't be an issue. I think having validation is more useful/user friendly than flexibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :)