Force the master username & password to be defined when not in a restore mode

This commit is contained in:
Ninir 2016-11-03 15:03:45 +01:00
parent c2041b7488
commit c250c10d4e
2 changed files with 12 additions and 3 deletions

View File

@ -328,6 +328,14 @@ func resourceAwsRedshiftClusterCreate(d *schema.ResourceData, meta interface{})
d.SetId(*resp.Cluster.ClusterIdentifier) d.SetId(*resp.Cluster.ClusterIdentifier)
} else { } else {
if _, ok := d.GetOk("master_password"); !ok {
return fmt.Errorf(`provider.aws: aws_redshift_cluster: %s: "master_password": required field is not set`, d.Get("cluster_identifier").(string))
}
if _, ok := d.GetOk("master_username"); !ok {
return fmt.Errorf(`provider.aws: aws_redshift_cluster: %s: "master_username": required field is not set`, d.Get("cluster_identifier").(string))
}
createOpts := &redshift.CreateClusterInput{ createOpts := &redshift.CreateClusterInput{
ClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)), ClusterIdentifier: aws.String(d.Get("cluster_identifier").(string)),
Port: aws.Int64(int64(d.Get("port").(int))), Port: aws.Int64(int64(d.Get("port").(int))),

View File

@ -34,10 +34,11 @@ string.
If you do not provide a name, Amazon Redshift will create a default database called `dev`. If you do not provide a name, Amazon Redshift will create a default database called `dev`.
* `node_type` - (Required) The node type to be provisioned for the cluster. * `node_type` - (Required) The node type to be provisioned for the cluster.
* `cluster_type` - (Optional) The cluster type to use. Either `single-node` or `multi-node`. * `cluster_type` - (Optional) The cluster type to use. Either `single-node` or `multi-node`.
* `master_password` - (Required) Password for the master DB user. Note that this may * `master_password` - (Required unless a `snapshot_identifier` is provided) Password for the master DB user.
show up in logs, and it will be stored in the state file. Password must contain at least 8 chars and Note that this may show up in logs, and it will be stored in the state file. Password must contain at least 8 chars and
contain at least one uppercase letter, one lowercase letter, and one number. contain at least one uppercase letter, one lowercase letter, and one number.
* `master_username` - (Required) Username for the master DB user * `master_username` - (Required unless a `snapshot_identifier` is provided) Username for the master DB user.
* `cluster_security_groups` - (Optional) A list of security groups to be associated with this cluster. * `cluster_security_groups` - (Optional) A list of security groups to be associated with this cluster.
* `vpc_security_group_ids` - (Optional) A list of Virtual Private Cloud (VPC) security groups to be associated with the cluster. * `vpc_security_group_ids` - (Optional) A list of Virtual Private Cloud (VPC) security groups to be associated with the cluster.
* `cluster_subnet_group_name` - (Optional) The name of a cluster subnet group to be associated with this cluster. If this parameter is not provided the resulting cluster will be deployed outside virtual private cloud (VPC). * `cluster_subnet_group_name` - (Optional) The name of a cluster subnet group to be associated with this cluster. If this parameter is not provided the resulting cluster will be deployed outside virtual private cloud (VPC).