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

f-aws_elasticache_serverless_cache:supports-minimum for cache_usage_l… #36766

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
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{
Copy link

Choose a reason for hiding this comment

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

What do you think of add a validator for the constraint aws imposes? You can set a minimum limit from 1 GB. and

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
Loading