aws_storagegateway_smb_file_share: cache_stale_timeout_in_seconds validation rejects 0, but the AWS API accepts it (blocks disabling cache refresh)
#48,876 opened on Jul 9, 2026
Repository metrics
- Stars
- (11,045 stars)
- PR merge metrics
- (PR metrics pending)
Description
Terraform and AWS Provider Version
Terraform / Provider versions: Terraform 1.14.x; hashicorp/aws - reproduced on both v5.100.0 and v6.53.0.
Affected Resource(s) or Data Source(s)
aws_storagegateway_smb_file_share
Expected Behavior
cache_attributes.cache_stale_timeout_in_seconds should accept 0 on aws_storagegateway_smb_file_share. The AWS Storage Gateway API documents 0 as a valid value meaning "cache refresh turned off" (Valid Values: 0 or 300-2,592,000), and it's what the console sets when "Automatic cache refresh from S3" is set to None. Terraform should be able to both create and update a share with this value so that cache refresh can be disabled, and so that shares already set to 0 (via console/CLI) can be managed without a permanent diff.
Actual Behavior
The provider validates the field as IntBetween(300, 2592000), so 0 is rejected at plan time and Terraform cannot set it - even though the AWS API accepts it. This has two consequences:
- A share's cache refresh cannot be disabled through Terraform (there is no accepted value that means "off").
- Shares set to
0out-of-band (console/CLI) never converge: the provider can't write0, and omitting thecache_attributesblock is a no-op at the API (AWS leaves the existing value unchanged), so the block-present0is read back on every refresh. The result is a permanent, non-convergent0 -> nullplan diff.
Reproduced on hashicorp/aws v5.100.0 and v6.53.0.
That the API accepts 0 is easily confirmed outside Terraform:
aws storagegateway update-smb-file-share --file-share-arn <arn> \
--cache-attributes CacheStaleTimeoutInSeconds=0
aws storagegateway describe-smb-file-shares --file-share-arn-list <arn> \
--query 'SMBFileShareInfoList[].CacheAttributes'
# => [ { "CacheStaleTimeoutInSeconds": 0 } ]
The resource docs also state only "300 to 2,592,000", which should be updated to include 0.
Relevant Error/Panic Output
Error: expected cache_attributes.0.cache_stale_timeout_in_seconds to be in the range (300 - 2592000), got 0
with aws_storagegateway_smb_file_share.example,
on main.tf line 16, in resource "aws_storagegateway_smb_file_share" "example":
16: cache_stale_timeout_in_seconds = 0
Sample Terraform Configuration
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "6.53.0" # also reproduces on 5.100.0
}
}
}
provider "aws" {
region = "eu-central-1"
}
resource "aws_storagegateway_smb_file_share" "example" {
gateway_arn = "arn:aws:storagegateway:eu-central-1:111122223333:gateway/sgw-12345678"
location_arn = "arn:aws:s3:::example-bucket"
role_arn = "arn:aws:iam::111122223333:role/example"
cache_attributes {
cache_stale_timeout_in_seconds = 0 # AWS API accepts 0 ("off"); provider rejects it
}
}
Steps to Reproduce
- Save the configuration above.
- Run
terraform init. - Run
terraform plan.
The plan fails immediately with the range-validation error - the value never reaches AWS, confirming this is provider-side validation, not an API rejection. (For contrast, the equivalent value set directly through the AWS CLI - update-smb-file-share --cache-attributes CacheStaleTimeoutInSeconds=0 -- succeeds.)
Debug Logging
No response
GenAI / LLM Assisted Development
n/a
Important Facts and References
No response
Would you like to implement a fix?
No