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

d/elasticache_replication_group: deprecation/add args to align with API #22667

Merged
merged 2 commits into from
Feb 2, 2022
Merged
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
11 changes: 11 additions & 0 deletions .changelog/22667.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:note
data-source/aws_elasticache_replication_group: The `replication_group_description` attribute has been deprecated. All configurations using `replication_group_description` should be updated to use the `description` attribute instead
```

```release-note:note
data-source/aws_elasticache_replication_group: The `number_cache_clusters` attribute has been deprecated. All configurations using `number_cache_clusters` should be updated to use the `num_cache_clusters` attribute instead
```

```release-note:enhancement
data-source/aws_elasticache_replication_group: Add `description`, `num_cache_clusters`, `num_node_groups`, and `replicas_per_node_group` attributes
```
29 changes: 26 additions & 3 deletions internal/service/elasticache/replication_group_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ func DataSourceReplicationGroup() *schema.Resource {
ValidateFunc: validateReplicationGroupID,
},
"replication_group_description": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: "Use description instead",
},
"arn": {
Type: schema.TypeString,
Expand All @@ -37,6 +38,10 @@ func DataSourceReplicationGroup() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
Expand All @@ -53,10 +58,19 @@ func DataSourceReplicationGroup() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"number_cache_clusters": {
"num_cache_clusters": {
Type: schema.TypeInt,
Computed: true,
},
"num_node_groups": {
Type: schema.TypeInt,
Computed: true,
},
"number_cache_clusters": {
Type: schema.TypeInt,
Computed: true,
Deprecated: "Use num_cache_clusters instead",
},
"member_clusters": {
Type: schema.TypeSet,
Computed: true,
Expand All @@ -70,6 +84,10 @@ func DataSourceReplicationGroup() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"replicas_per_node_group": {
Type: schema.TypeInt,
Computed: true,
},
"snapshot_window": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -93,6 +111,7 @@ func dataSourceReplicationGroupRead(d *schema.ResourceData, meta interface{}) er
}

d.SetId(aws.StringValue(rg.ReplicationGroupId))
d.Set("description", rg.Description)
d.Set("replication_group_description", rg.Description)
d.Set("arn", rg.ARN)
d.Set("auth_token_enabled", rg.AuthTokenEnabled)
Expand Down Expand Up @@ -129,11 +148,15 @@ func dataSourceReplicationGroupRead(d *schema.ResourceData, meta interface{}) er
d.Set("primary_endpoint_address", rg.NodeGroups[0].PrimaryEndpoint.Address)
d.Set("reader_endpoint_address", rg.NodeGroups[0].ReaderEndpoint.Address)
}

d.Set("num_cache_clusters", len(rg.MemberClusters))
d.Set("number_cache_clusters", len(rg.MemberClusters))
if err := d.Set("member_clusters", flex.FlattenStringList(rg.MemberClusters)); err != nil {
return fmt.Errorf("error setting member_clusters: %w", err)
}
d.Set("node_type", rg.CacheNodeType)
d.Set("num_node_groups", len(rg.NodeGroups))
d.Set("replicas_per_node_group", len(rg.NodeGroups[0].NodeGroupMembers)-1)
d.Set("snapshot_window", rg.SnapshotWindow)
d.Set("snapshot_retention_limit", rg.SnapshotRetentionLimit)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ func TestAccElastiCacheReplicationGroupDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceName, "multi_az_enabled", resourceName, "multi_az_enabled"),
resource.TestCheckResourceAttrPair(dataSourceName, "member_clusters.#", resourceName, "member_clusters.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "node_type", resourceName, "node_type"),
resource.TestCheckResourceAttrPair(dataSourceName, "num_cache_clusters", resourceName, "number_cache_clusters"),
resource.TestCheckResourceAttrPair(dataSourceName, "number_cache_clusters", resourceName, "number_cache_clusters"),
resource.TestCheckResourceAttrPair(dataSourceName, "port", resourceName, "port"),
resource.TestCheckResourceAttrPair(dataSourceName, "primary_endpoint_address", resourceName, "primary_endpoint_address"),
resource.TestCheckResourceAttrPair(dataSourceName, "reader_endpoint_address", resourceName, "reader_endpoint_address"),
resource.TestCheckResourceAttrPair(dataSourceName, "description", resourceName, "replication_group_description"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_group_description", resourceName, "replication_group_description"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_group_id", resourceName, "replication_group_id"),
resource.TestCheckResourceAttrPair(dataSourceName, "snapshot_window", resourceName, "snapshot_window"),
Expand Down Expand Up @@ -61,7 +63,9 @@ func TestAccElastiCacheReplicationGroupDataSource_clusterMode(t *testing.T) {
resource.TestCheckResourceAttrPair(dataSourceName, "multi_az_enabled", resourceName, "multi_az_enabled"),
resource.TestCheckResourceAttrPair(dataSourceName, "configuration_endpoint_address", resourceName, "configuration_endpoint_address"),
resource.TestCheckResourceAttrPair(dataSourceName, "node_type", resourceName, "node_type"),
resource.TestCheckResourceAttrPair(dataSourceName, "num_node_groups", resourceName, "cluster_mode.0.num_node_groups"),
resource.TestCheckResourceAttrPair(dataSourceName, "port", resourceName, "port"),
resource.TestCheckResourceAttrPair(dataSourceName, "replicas_per_node_group", resourceName, "cluster_mode.0.replicas_per_node_group"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_group_description", resourceName, "replication_group_description"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_group_id", resourceName, "replication_group_id"),
),
Expand Down
8 changes: 6 additions & 2 deletions website/docs/d/elasticache_replication_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ The following arguments are supported:

In addition to all arguments above, the following attributes are exported:

* `replication_group_description` - The description of the replication group.
* `description` - The description of the replication group.
* `arn` - The Amazon Resource Name (ARN) of the created ElastiCache Replication Group.
* `auth_token_enabled` - Specifies whether an AuthToken (password) is enabled.
* `automatic_failover_enabled` - A flag whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails.
* `node_type` – The cluster node type.
* `number_cache_clusters` – The number of cache clusters that the replication group has.
* `num_cache_clusters` – The number of cache clusters that the replication group has.
* `num_node_groups` - Number of node groups (shards) for the replication group.
* `number_cache_clusters` – (**Deprecated** use `num_cache_clusters` instead) The number of cache clusters that the replication group has.
* `member_clusters` - The identifiers of all the nodes that are part of this replication group.
* `multi_az_enabled` - Specifies whether Multi-AZ Support is enabled for the replication group.
* `replicas_per_node_group` - Number of replica nodes in each node group.
* `replication_group_description` - (**Deprecated** use `description` instead) The description of the replication group.
* `snapshot_window` - The daily time range (in UTC) during which ElastiCache begins taking a daily snapshot of your node group (shard).
* `snapshot_retention_limit` - The number of days for which ElastiCache retains automatic cache cluster snapshots before deleting them.
* `port` – The port number on which the configuration endpoint will accept connections.
Expand Down