-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue #4566 add new attribute dns_name in aws_redshift_cluster #4582
Changes from 3 commits
3592346
5d988fa
304aaa2
0de7d9f
1898b32
1b64763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,12 @@ func resourceAwsRedshiftCluster() *schema.Resource { | |
Computed: true, | ||
}, | ||
|
||
"dns_name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This attribute is not configurable so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I just used the previous output attribute |
||
Computed: true, | ||
}, | ||
|
||
"cluster_public_key": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
|
@@ -567,6 +573,7 @@ func resourceAwsRedshiftClusterRead(d *schema.ResourceData, meta interface{}) er | |
if rsc.Endpoint.Port != nil { | ||
endpoint = fmt.Sprintf("%s:%d", endpoint, *rsc.Endpoint.Port) | ||
} | ||
d.Set("dns_name", rsc.Endpoint.Address) | ||
d.Set("port", rsc.Endpoint.Port) | ||
d.Set("endpoint", endpoint) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,32 @@ func TestAccAWSRedshiftCluster_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSRedshiftCluster_dnsName(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
var v redshift.Cluster | ||
|
||
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, we have a helper for this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a bunch of PRs related to replacing all these across the codebase so you won't need to do anything: #4625 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh ok, I ll revert it. |
||
config := testAccAWSRedshiftClusterConfig_basic(ri) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSRedshiftClusterDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSRedshiftClusterExists("aws_redshift_cluster.default", &v), | ||
resource.TestCheckResourceAttr( | ||
"aws_redshift_cluster.default", "cluster_type", "single-node"), | ||
resource.TestCheckResourceAttr( | ||
"aws_redshift_cluster.default", "publicly_accessible", "true"), | ||
testAccCheckAWSRedshiftClusterDNSName(&v, ri), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can verify the value from the state using resource.TestMatchResourceAttr("aws_redshift_cluster.default", "address", regexp.MustCompile(fmt.Sprintf("^tf-redshift-cluster-%d.*\.redshift\..*", ri))) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, done. |
||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSRedshiftCluster_withFinalSnapshot(t *testing.T) { | ||
var v redshift.Cluster | ||
|
||
|
@@ -630,6 +656,23 @@ func testAccCheckAWSRedshiftClusterMasterUsername(c *redshift.Cluster, value str | |
} | ||
} | ||
|
||
func testAccCheckAWSRedshiftClusterDNSName(c *redshift.Cluster, rInt int) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
if c.Endpoint == nil { | ||
return fmt.Errorf("Expected cluster Endpoint to be set, got nil") | ||
} | ||
|
||
//validate the cluster address | ||
str := fmt.Sprintf("tf-redshift-cluster-%d.?[a-zA-Z0-9].*?.us-west-2.redshift.amazonaws.com", rInt) | ||
re := regexp.MustCompile(str) | ||
if !re.MatchString(*c.Endpoint.Address) { | ||
return fmt.Errorf("Expected cluster DNS name, got %s", *c.Endpoint.Address) | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func TestResourceAWSRedshiftClusterIdentifierValidation(t *testing.T) { | ||
cases := []struct { | ||
Value string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not call this
address
to match the API?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but I checked the other resources to see how they are naming the address attributes(aws_alb, aws_elb) and used the same naming convention.