Updated Redshift Documentation and Added Test Cases for Redshift Enchaned VPC routing

This commit is contained in:
Anshul Sharma 2016-11-08 18:13:10 +05:30
parent 1030cc1344
commit e9821eaced
3 changed files with 32 additions and 4 deletions

View File

@ -481,6 +481,7 @@ func resourceAwsRedshiftClusterRead(d *schema.ResourceData, meta interface{}) er
d.Set("cluster_subnet_group_name", rsc.ClusterSubnetGroupName) d.Set("cluster_subnet_group_name", rsc.ClusterSubnetGroupName)
d.Set("availability_zone", rsc.AvailabilityZone) d.Set("availability_zone", rsc.AvailabilityZone)
d.Set("encrypted", rsc.Encrypted) d.Set("encrypted", rsc.Encrypted)
d.Set("enhanced_vpc_routing", rsc.EnhancedVpcRouting)
d.Set("kms_key_id", rsc.KmsKeyId) d.Set("kms_key_id", rsc.KmsKeyId)
d.Set("automated_snapshot_retention_period", rsc.AutomatedSnapshotRetentionPeriod) d.Set("automated_snapshot_retention_period", rsc.AutomatedSnapshotRetentionPeriod)
d.Set("preferred_maintenance_window", rsc.PreferredMaintenanceWindow) d.Set("preferred_maintenance_window", rsc.PreferredMaintenanceWindow)
@ -624,6 +625,11 @@ func resourceAwsRedshiftClusterUpdate(d *schema.ResourceData, meta interface{})
requestUpdate = true requestUpdate = true
} }
if d.HasChange("enhanced_vpc_routing") {
req.EnhancedVpcRouting = aws.Bool(d.Get("enhanced_vpc_routing").(bool))
requestUpdate = true
}
if requestUpdate { if requestUpdate {
log.Printf("[INFO] Modifying Redshift Cluster: %s", d.Id()) log.Printf("[INFO] Modifying Redshift Cluster: %s", d.Id())
log.Printf("[DEBUG] Redshift Cluster Modify options: %s", req) log.Printf("[DEBUG] Redshift Cluster Modify options: %s", req)

View File

@ -42,7 +42,8 @@ func TestAccAWSRedshiftCluster_enhancedVpcRoutingEnabled(t *testing.T) {
var v redshift.Cluster var v redshift.Cluster
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int() ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
config := fmt.Sprintf(testAccAWSRedshiftClusterConfig_enhancedVpcRoutingEnabled, ri) preConfig := fmt.Sprintf(testAccAWSRedshiftClusterConfig_enhancedVpcRoutingEnabled, ri)
postConfig := fmt.Sprintf(testAccAWSRedshiftClusterConfig_enhancedVpcRoutingDisabled, ri)
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
@ -50,15 +51,21 @@ func TestAccAWSRedshiftCluster_enhancedVpcRoutingEnabled(t *testing.T) {
CheckDestroy: testAccCheckAWSRedshiftClusterDestroy, CheckDestroy: testAccCheckAWSRedshiftClusterDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: config, Config: preConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftClusterExists("aws_redshift_cluster.default", &v), testAccCheckAWSRedshiftClusterExists("aws_redshift_cluster.default", &v),
resource.TestCheckResourceAttr(
"aws_redshift_cluster.default", "cluster_type", "single-node"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_cluster.default", "enhanced_vpc_routing", "true"), "aws_redshift_cluster.default", "enhanced_vpc_routing", "true"),
), ),
}, },
resource.TestStep{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftClusterExists("aws_redshift_cluster.default", &v),
resource.TestCheckResourceAttr(
"aws_redshift_cluster.default", "enhanced_vpc_routing", "false"),
),
},
}, },
}) })
} }
@ -509,6 +516,20 @@ resource "aws_redshift_cluster" "default" {
} }
` `
var testAccAWSRedshiftClusterConfig_enhancedVpcRoutingDisabled = `
resource "aws_redshift_cluster" "default" {
cluster_identifier = "tf-redshift-cluster-%d"
availability_zone = "us-west-2a"
database_name = "mydb"
master_username = "foo_test"
master_password = "Mustbe8characters"
node_type = "dc1.large"
automated_snapshot_retention_period = 0
allow_version_upgrade = false
enhanced_vpc_routing = false
}
`
var testAccAWSRedshiftClusterConfig_loggingDisabled = ` var testAccAWSRedshiftClusterConfig_loggingDisabled = `
resource "aws_redshift_cluster" "default" { resource "aws_redshift_cluster" "default" {
cluster_identifier = "tf-redshift-cluster-%d" cluster_identifier = "tf-redshift-cluster-%d"

View File

@ -54,6 +54,7 @@ string.
* `number_of_nodes` - (Optional) The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node. Default is 1. * `number_of_nodes` - (Optional) The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node. Default is 1.
* `publicly_accessible` - (Optional) If true, the cluster can be accessed from a public network. Default is `true`. * `publicly_accessible` - (Optional) If true, the cluster can be accessed from a public network. Default is `true`.
* `encrypted` - (Optional) If true , the data in the cluster is encrypted at rest. * `encrypted` - (Optional) If true , the data in the cluster is encrypted at rest.
* `enhanced_vpc_routing` - (Optional) If true , enhanced VPC routing is enabled.
* `kms_key_id` - (Optional) The ARN for the KMS encryption key. When specifying `kms_key_id`, `encrypted` needs to be set to true * `kms_key_id` - (Optional) The ARN for the KMS encryption key. When specifying `kms_key_id`, `encrypted` needs to be set to true
* `elastic_ip` - (Optional) The Elastic IP (EIP) address for the cluster. * `elastic_ip` - (Optional) The Elastic IP (EIP) address for the cluster.
* `skip_final_snapshot` - (Optional) Determines whether a final snapshot of the cluster is created before Amazon Redshift deletes the cluster. If true , a final cluster snapshot is not created. If false , a final cluster snapshot is created before the cluster is deleted. Default is true. * `skip_final_snapshot` - (Optional) Determines whether a final snapshot of the cluster is created before Amazon Redshift deletes the cluster. If true , a final cluster snapshot is not created. If false , a final cluster snapshot is created before the cluster is deleted. Default is true.