Skip to content

Commit

Permalink
Merge branch 'bculberson-GH-7212'
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad committed Feb 22, 2019
2 parents bca0296 + cc6cfc0 commit 7b58034
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
27 changes: 20 additions & 7 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,25 +712,34 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}

} else {
if _, ok := d.GetOk("master_password"); !ok {
return fmt.Errorf(`provider.aws: aws_rds_cluster: %s: "master_password": required field is not set`, d.Get("database_name").(string))
}

if _, ok := d.GetOk("master_username"); !ok {
return fmt.Errorf(`provider.aws: aws_rds_cluster: %s: "master_username": required field is not set`, d.Get("database_name").(string))
if _, ok := d.GetOk("global_cluster_identifier"); !ok {
if _, ok := d.GetOk("master_password"); !ok {
return fmt.Errorf(`provider.aws: aws_db_instance: %s: "master_password": required field is not set`, d.Get("database_name").(string))
}

if _, ok := d.GetOk("master_username"); !ok {
return fmt.Errorf(`provider.aws: aws_db_instance: %s: "master_username": required field is not set`, d.Get("database_name").(string))
}
}

createOpts := &rds.CreateDBClusterInput{
DBClusterIdentifier: aws.String(identifier),
DeletionProtection: aws.Bool(d.Get("deletion_protection").(bool)),
Engine: aws.String(d.Get("engine").(string)),
EngineMode: aws.String(d.Get("engine_mode").(string)),
MasterUserPassword: aws.String(d.Get("master_password").(string)),
MasterUsername: aws.String(d.Get("master_username").(string)),
ScalingConfiguration: expandRdsScalingConfiguration(d.Get("scaling_configuration").([]interface{})),
Tags: tags,
}

if v, ok := d.GetOk("master_password"); ok && v.(string) != "" {
createOpts.MasterUserPassword = aws.String(v.(string))
}

if v, ok := d.GetOk("master_username"); ok && v.(string) != "" {
createOpts.MasterUsername = aws.String(v.(string))
}

// Need to check value > 0 due to:
// InvalidParameterValue: Backtrack is not enabled for the aurora-postgresql engine.
if v, ok := d.GetOk("backtrack_window"); ok && v.(int) > 0 {
Expand Down Expand Up @@ -785,6 +794,10 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
createOpts.KmsKeyId = aws.String(attr.(string))
}

if attr, ok := d.GetOk("source_region"); ok {
createOpts.SourceRegion = aws.String(attr.(string))
}

if attr, ok := d.GetOk("iam_database_authentication_enabled"); ok {
createOpts.EnableIAMDatabaseAuthentication = aws.Bool(attr.(bool))
}
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/rds_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ The following arguments are supported:
* `cluster_identifier_prefix` - (Optional, Forces new resource) Creates a unique cluster identifier beginning with the specified prefix. Conflicts with `cluster_identifier`.
* `database_name` - (Optional) Name for an automatically created database on cluster creation. There are different naming restrictions per database engine: [RDS Naming Constraints][5]
* `deletion_protection` - (Optional) If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to `true`. The default is `false`.
* `master_password` - (Required unless a `snapshot_identifier` is provided) Password for the master DB user. Note that this may
* `master_password` - (Required unless a `snapshot_identifier` or `global_cluster_identifier` is provided) Password for the master DB user. Note that this may
show up in logs, and it will be stored in the state file. Please refer to the [RDS Naming Constraints][5]
* `master_username` - (Required unless a `snapshot_identifier` is provided) Username for the master DB user. Please refer to the [RDS Naming Constraints][5]
* `master_username` - (Required unless a `snapshot_identifier` or `global_cluster_identifier` is provided) Username for the master DB user. Please refer to the [RDS Naming Constraints][5]
* `final_snapshot_identifier` - (Optional) The name of your final DB snapshot
when this DB cluster is deleted. If omitted, no final snapshot will be
made.
Expand All @@ -103,6 +103,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per
* `vpc_security_group_ids` - (Optional) List of VPC security groups to associate
with the Cluster
* `snapshot_identifier` - (Optional) Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot.
* `global_cluster_identifier` - (Optional) The global cluster identifier specified on [`aws_rds_global_cluster`](/docs/providers/aws/r/rds_global_cluster.html).
* `storage_encrypted` - (Optional) Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode`.
* `replication_source_identifier` - (Optional) ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica.
* `apply_immediately` - (Optional) Specifies whether any cluster modifications
Expand Down

0 comments on commit 7b58034

Please sign in to comment.