Skip to content

Commit

Permalink
Merge pull request #36766 from nikhil-goenka/f-aws_elasticache_server…
Browse files Browse the repository at this point in the history
…less_cache-supports-minimum

f-aws_elasticache_serverless_cache:supports-minimum for cache_usage_l…
  • Loading branch information
johnsonaj committed Apr 12, 2024
2 parents 70a5bc9 + e9d828d commit 9222aea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/36766.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/serverless_cache: Add `minimum` attribute in `cache_usage_limits.data_storage` and `cache_usage_limits.ecpu_per_second`
```
21 changes: 19 additions & 2 deletions internal/service/elasticache/serverless_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ func (r *serverlessCacheResource) Schema(ctx context.Context, request resource.S
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"maximum": schema.Int64Attribute{
Required: true,
Optional: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.RequiresReplace(),
},
},
"minimum": schema.Int64Attribute{
Optional: true,
PlanModifiers: []planmodifier.Int64{
int64planmodifier.RequiresReplace(),
},
Expand All @@ -216,7 +222,16 @@ func (r *serverlessCacheResource) Schema(ctx context.Context, request resource.S
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"maximum": schema.Int64Attribute{
Required: true,
Optional: true,
Validators: []validator.Int64{
int64validator.Between(1000, 15000000),
},
PlanModifiers: []planmodifier.Int64{
int64planmodifier.RequiresReplace(),
},
},
"minimum": schema.Int64Attribute{
Optional: true,
Validators: []validator.Int64{
int64validator.Between(1000, 15000000),
},
Expand Down Expand Up @@ -482,11 +497,13 @@ type cacheUsageLimitsModel struct {

type dataStorageModel struct {
Maximum types.Int64 `tfsdk:"maximum"`
Minimum types.Int64 `tfsdk:"minimum"`
Unit fwtypes.StringEnum[awstypes.DataStorageUnit] `tfsdk:"unit"`
}

type ecpuPerSecondModel struct {
Maximum types.Int64 `tfsdk:"maximum"`
Minimum types.Int64 `tfsdk:"minimum"`
}

type endpointModel struct {
Expand Down
9 changes: 8 additions & 1 deletion internal/service/elasticache/serverless_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func TestAccElastiCacheServerlessCache_full(t *testing.T) {
testAccCheckServerlessCacheExists(ctx, resourceName, &serverlessElasticCache),
resource.TestCheckResourceAttrSet(resourceName, "arn"),
resource.TestCheckResourceAttrSet(resourceName, "cache_usage_limits.#"),
resource.TestCheckResourceAttr(resourceName, "cache_usage_limits.0.data_storage.0.maximum", "10"),
resource.TestCheckResourceAttr(resourceName, "cache_usage_limits.0.data_storage.0.minimum", "1"),
resource.TestCheckResourceAttr(resourceName, "cache_usage_limits.0.data_storage.0.unit", "GB"),
resource.TestCheckResourceAttr(resourceName, "cache_usage_limits.0.ecpu_per_second.0.maximum", "10000"),
resource.TestCheckResourceAttr(resourceName, "cache_usage_limits.0.ecpu_per_second.0.minimum", "1000"),
resource.TestCheckResourceAttrSet(resourceName, "create_time"),
resource.TestCheckResourceAttrSet(resourceName, "endpoint.#"),
resource.TestCheckResourceAttrSet(resourceName, "engine"),
Expand Down Expand Up @@ -484,10 +489,12 @@ resource "aws_elasticache_serverless_cache" "test" {
cache_usage_limits {
data_storage {
maximum = 10
minimum = 1
unit = "GB"
}
ecpu_per_second {
maximum = 1000
maximum = 10000
minimum = 1000
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/elasticache_serverless_cache.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ The following arguments are optional:

### DataStorage Configuration

* `minimum` - The lower limit for data storage the cache is set to use. Must be between 1 and 5,000.
* `maximum` - The upper limit for data storage the cache is set to use. Must be between 1 and 5,000.
* `unit` - The unit that the storage is measured in, in GB.

### ECPUPerSecond Configuration

* `minimum` - The minimum number of ECPUs the cache can consume per second. Must be between 1,000 and 15,000,000.
* `maximum` - The maximum number of ECPUs the cache can consume per second. Must be between 1,000 and 15,000,000.

## Attribute Reference
Expand Down

0 comments on commit 9222aea

Please sign in to comment.