Merge pull request #9950 from optimisticanshul/9928-aws-redshift-enhanced-vpc-routing

Added AWS Redshift Enhanced VPC Routing
This commit is contained in:
Paddy 2016-11-08 11:02:37 -08:00 committed by GitHub
commit 78f8fea1fa
3 changed files with 81 additions and 0 deletions

View File

@ -159,6 +159,12 @@ func resourceAwsRedshiftCluster() *schema.Resource {
Computed: true,
},
"enhanced_vpc_routing": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"kms_key_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
@ -302,6 +308,10 @@ func resourceAwsRedshiftClusterCreate(d *schema.ResourceData, meta interface{})
restoreOpts.ElasticIp = aws.String(v.(string))
}
if v, ok := d.GetOk("enhanced_vpc_routing"); ok {
restoreOpts.EnhancedVpcRouting = aws.Bool(v.(bool))
}
if v, ok := d.GetOk("iam_roles"); ok {
restoreOpts.IamRoles = expandStringList(v.(*schema.Set).List())
}
@ -366,6 +376,10 @@ func resourceAwsRedshiftClusterCreate(d *schema.ResourceData, meta interface{})
createOpts.Encrypted = aws.Bool(v.(bool))
}
if v, ok := d.GetOk("enhanced_vpc_routing"); ok {
createOpts.EnhancedVpcRouting = aws.Bool(v.(bool))
}
if v, ok := d.GetOk("kms_key_id"); ok {
createOpts.KmsKeyId = aws.String(v.(string))
}
@ -467,6 +481,7 @@ func resourceAwsRedshiftClusterRead(d *schema.ResourceData, meta interface{}) er
d.Set("cluster_subnet_group_name", rsc.ClusterSubnetGroupName)
d.Set("availability_zone", rsc.AvailabilityZone)
d.Set("encrypted", rsc.Encrypted)
d.Set("enhanced_vpc_routing", rsc.EnhancedVpcRouting)
d.Set("kms_key_id", rsc.KmsKeyId)
d.Set("automated_snapshot_retention_period", rsc.AutomatedSnapshotRetentionPeriod)
d.Set("preferred_maintenance_window", rsc.PreferredMaintenanceWindow)
@ -610,6 +625,11 @@ func resourceAwsRedshiftClusterUpdate(d *schema.ResourceData, meta interface{})
requestUpdate = true
}
if d.HasChange("enhanced_vpc_routing") {
req.EnhancedVpcRouting = aws.Bool(d.Get("enhanced_vpc_routing").(bool))
requestUpdate = true
}
if requestUpdate {
log.Printf("[INFO] Modifying Redshift Cluster: %s", d.Id())
log.Printf("[DEBUG] Redshift Cluster Modify options: %s", req)

View File

@ -38,6 +38,38 @@ func TestAccAWSRedshiftCluster_basic(t *testing.T) {
})
}
func TestAccAWSRedshiftCluster_enhancedVpcRoutingEnabled(t *testing.T) {
var v redshift.Cluster
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
preConfig := fmt.Sprintf(testAccAWSRedshiftClusterConfig_enhancedVpcRoutingEnabled, ri)
postConfig := fmt.Sprintf(testAccAWSRedshiftClusterConfig_enhancedVpcRoutingDisabled, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRedshiftClusterDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftClusterExists("aws_redshift_cluster.default", &v),
resource.TestCheckResourceAttr(
"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"),
),
},
},
})
}
func TestAccAWSRedshiftCluster_loggingEnabled(t *testing.T) {
var v redshift.Cluster
@ -470,6 +502,34 @@ resource "aws_redshift_cluster" "default" {
allow_version_upgrade = false
}`
var testAccAWSRedshiftClusterConfig_enhancedVpcRoutingEnabled = `
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 = true
}
`
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 = `
resource "aws_redshift_cluster" "default" {
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.
* `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.
* `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
* `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.