Skip to content

Commit

Permalink
Merge pull request #5520 from bsiegel/aws_rds_cluster_encryption
Browse files Browse the repository at this point in the history
Add storage_encrypted as an optional parameter to aws_rds_cluster
  • Loading branch information
stack72 committed Mar 9, 2016
2 parents ed1126e + fc7e9fc commit b5e6cb5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
9 changes: 9 additions & 0 deletions builtin/providers/aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ func resourceAwsRDSCluster() *schema.Resource {
Computed: true,
},

"storage_encrypted": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},

"final_snapshot_identifier": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -167,6 +174,7 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
Engine: aws.String("aurora"),
MasterUserPassword: aws.String(d.Get("master_password").(string)),
MasterUsername: aws.String(d.Get("master_username").(string)),
StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)),
}

if v := d.Get("database_name"); v.(string) != "" {
Expand Down Expand Up @@ -276,6 +284,7 @@ func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error {
d.Set("engine", dbc.Engine)
d.Set("master_username", dbc.MasterUsername)
d.Set("port", dbc.Port)
d.Set("storage_encrypted", dbc.StorageEncrypted)
d.Set("backup_retention_period", dbc.BackupRetentionPeriod)
d.Set("preferred_backup_window", dbc.PreferredBackupWindow)
d.Set("preferred_maintenance_window", dbc.PreferredMaintenanceWindow)
Expand Down
35 changes: 35 additions & 0 deletions builtin/providers/aws/resource_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ func TestAccAWSRDSCluster_basic(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists("aws_rds_cluster.default", &v),
resource.TestCheckResourceAttr(
"aws_rds_cluster.default", "storage_encrypted", "false"),
),
},
},
})
}

func TestAccAWSRDSCluster_encrypted(t *testing.T) {
var v rds.DBCluster

ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
encConfig := fmt.Sprintf(testAccAWSClusterConfig_encrypted, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSClusterDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: encConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSClusterExists("aws_rds_cluster.default", &v),
resource.TestCheckResourceAttr(
"aws_rds_cluster.default", "storage_encrypted", "true"),
),
},
},
Expand Down Expand Up @@ -150,6 +175,16 @@ resource "aws_rds_cluster" "default" {
master_password = "mustbeeightcharaters"
}`

var testAccAWSClusterConfig_encrypted = `
resource "aws_rds_cluster" "default" {
cluster_identifier = "tf-aurora-cluster-%d"
availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]
database_name = "mydb"
master_username = "foo"
master_password = "mustbeeightcharaters"
storage_encrypted = true
}`

var testAccAWSClusterConfig_backups = `
resource "aws_rds_cluster" "default" {
cluster_identifier = "tf-aurora-cluster-%d"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per
* `port` - (Optional) The port on which the DB accepts connections
* `vpc_security_group_ids` - (Optional) List of VPC security groups to associate
with the Cluster
* `storage_encrypted` - (Optional) Specifies whether the DB cluster is encrypted. The default is `false` if not specified.
* `apply_immediately` - (Optional) Specifies whether any cluster modifications
are applied immediately, or during the next maintenance window. Default is
`false`. See [Amazon RDS Documentation for more information.](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html)
Expand All @@ -97,7 +98,7 @@ The following attributes are exported:
* `port` - The database port
* `status` - The RDS instance status
* `username` - The master username for the database
* `storage_encrypted` - Specifies whether the DB instance is encrypted
* `storage_encrypted` - Specifies whether the DB cluster is encrypted
* `preferred_backup_window` - The daily time range during which the backups happen

[1]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html
Expand Down

0 comments on commit b5e6cb5

Please sign in to comment.