Skip to content
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

data_source/aws_elasticache_replication_group: Output read_endpoint_addresses #6014

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions aws/data_source_aws_elasticache_replication_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func dataSourceAwsElasticacheReplicationGroup() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"read_endpoint_addresses": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},
"number_cache_clusters": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -110,6 +116,15 @@ func dataSourceAwsElasticacheReplicationGroupRead(d *schema.ResourceData, meta i
}
d.Set("port", rg.NodeGroups[0].PrimaryEndpoint.Port)
d.Set("primary_endpoint_address", rg.NodeGroups[0].PrimaryEndpoint.Address)

var rEndpoints []*string
for _, member := range rg.NodeGroups[0].NodeGroupMembers {
rEndpoints = append(rEndpoints, member.ReadEndpoint.Address)
}
if err := d.Set("read_endpoint_addresses", flattenStringList(rEndpoints)); err != nil {
return fmt.Errorf("error setting read_endpoint_addresses: %s", err)
}

}
d.Set("number_cache_clusters", len(rg.MemberClusters))
if err := d.Set("member_clusters", flattenStringList(rg.MemberClusters)); err != nil {
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_elasticache_replication_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestAccDataSourceAwsElasticacheReplicationGroup_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "automatic_failover_enabled", "true"),
resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "port", "6379"),
resource.TestCheckResourceAttrSet("data.aws_elasticache_replication_group.bar", "primary_endpoint_address"),
resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "read_endpoint_addresses", "2"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be read_endpoint_addresses.# instead if you want to ensure there are two addresses in the list.

resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "number_cache_clusters", "2"),
resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "member_clusters.#", "2"),
resource.TestCheckResourceAttr("data.aws_elasticache_replication_group.bar", "node_type", "cache.m1.small"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/elasticache_replication_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ In addition to all arguments above, the following attributes are exported:
* `port` – The port number on which the configuration endpoint will accept connections.
* `configuration_endpoint_address` - The configuration endpoint address to allow host discovery.
* `primary_endpoint_address` - The endpoint of the primary node in this node group (shard).
* `read_endpoint_addresses` - Reader endpoints of the nodes in this node group.