Resource Documentation
Resource Documentation Structure
Each resource requires comprehensive documentation covering usage, configuration, and management.
Page Structure
Resource documentation includes:
---
page_title: "Resource: cachecloud_cache"
subcategory: ""
description: |-
Manages a CacheCloud cache instance.
---
# cachecloud_cache (Resource)
[Description]
## Example Usage
[Examples]
## Schema
[Argument Reference]
[Attribute Reference]
## Timeouts
[Timeout Configuration]
## Import
[Import Instructions]
Writing Descriptions
Resource Description
Describe what the resource manages and key capabilities:
# cachecloud_cache (Resource)
Manages a CacheCloud cache instance. The cache resource provides a fully managed Redis or Memcached cache with automatic backups, monitoring, and scaling capabilities.
Use this resource to create, manage, and delete cache instances. The cache can be configured with various node types, replica counts, and backup settings.
## Key Features
- **Multi-Engine Support**: Redis and Memcached
- **Automatic Backups**: Scheduled backups with configurable retention
- **High Availability**: Multi-node clusters with automatic failover
- **Monitoring**: Built-in metrics and alarms
- **Security**: Encryption in transit and at rest
When to Use
Help users understand use cases:
## Use Cases
- **Session Storage**: Low-latency session data for web applications
- **Cache Layer**: Reduce database load with cached query results
- **Pub/Sub**: Real-time messaging with Redis pub/sub
- **Leaderboards**: Sorted sets for gaming leaderboards
- **Rate Limiting**: Token bucket implementation with expiring keys
Example Usage
Basic Example
Start with a minimal, working configuration:
## Example Usage
### Basic Configuration
```terraform
resource "cachecloud_cache" "basic" {
name = "my-cache"
engine = "redis"
node_type = "cache.t3.micro"
}
### Complete Example
Show realistic production configuration:
```markdown
### Production Configuration
```terraform
resource "cachecloud_cache" "production" {
name = "prod-api-cache"
engine = "redis"
version = "7.0"
node_type = "cache.m5.large"
num_nodes = 3
# High availability
multi_az_enabled = true
automatic_failover_enabled = true
# Backups
backup_enabled = true
backup_retention_days = 30
backup_window = "03:00-05:00"
# Maintenance
maintenance_window = "mon:04:00-mon:05:00"
# Security
encryption_at_rest_enabled = true
encryption_in_transit_enabled = true
# Monitoring
monitoring_enabled = true
alarm_cpu_threshold = 75
alarm_memory_threshold = 80
# Network
vpc_id = aws_vpc.main.id
subnet_ids = aws_subnet.private[*].id
# Tags
tags = {
Environment = "production"
Application = "api"
ManagedBy = "terraform"
}
}
### Multiple Scenarios
Document common patterns:
```markdown
### Memcached Cache
```terraform
resource "cachecloud_cache" "memcached" {
name = "session-cache"
engine = "memcached"
node_type = "cache.t3.small"
num_nodes = 2
port = 11211
}
Redis with Cluster Mode
resource "cachecloud_cache" "redis_cluster" {
name = "redis-cluster"
engine = "redis"
node_type = "cache.m5.large"
cluster_mode_enabled = true
num_shards = 3
replicas_per_shard = 2
}
Development Environment
resource "cachecloud_cache" "dev" {
name = "dev-cache"
engine = "redis"
node_type = "cache.t3.micro"
num_nodes = 1
# Minimal settings for development
backup_enabled = false
monitoring_enabled = false
tags = {
Environment = "development"
AutoShutdown = "true"
}
}
## Schema Documentation
### Argument Reference
Document all configuration attributes:
```markdown
## Schema
### Required
- `name` (String) The name of the cache. Must be unique within your account. Names must be 3-63 characters, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens.
- `engine` (String) The cache engine type. Valid values: `redis`, `memcached`.
### Optional
- `node_type` (String) The compute and memory capacity of the nodes. See [Node Types](#node-types) for available types. Defaults to `cache.t3.micro`.
- `num_nodes` (Number) Number of cache nodes in the cluster. Valid range: 1-90. Defaults to `1`. Memcached supports up to 20 nodes.
- `version` (String) The engine version to use. See [Supported Versions](#supported-versions). Defaults to the latest version.
- `port` (Number) The port number on which the cache accepts connections. Valid range: 1024-65535. Redis defaults to `6379`, Memcached to `11211`.
- `backup_enabled` (Boolean) Enable automatic backups. Only available for Redis. Defaults to `false`.
- `backup_retention_days` (Number) Number of days to retain automated backups. Valid range: 1-35. Required if `backup_enabled` is `true`.
- `backup_window` (String) Daily time range during which automated backups are created (UTC). Format: `HH:MM-HH:MM` (e.g., `03:00-05:00`). Must be at least 60 minutes.
- `maintenance_window` (String) Weekly time range for maintenance (UTC). Format: `ddd:HH:MM-ddd:HH:MM` (e.g., `mon:04:00-mon:05:00`).
- `encryption_at_rest_enabled` (Boolean) Enable encryption at rest using AWS KMS. Defaults to `false`.
- `encryption_in_transit_enabled` (Boolean) Enable encryption in transit (TLS). Defaults to `false`.
- `vpc_id` (String) The ID of the VPC where the cache will be created.
- `subnet_ids` (List of String) List of subnet IDs for the cache. Must be in the same VPC.
- `security_group_ids` (List of String) List of security group IDs to associate with the cache.
- `parameter_group` (String) The name of the parameter group to associate with this cache.
- `tags` (Map of String) Key-value map of resource tags. Maximum 50 tags.
### Read-Only
- `id` (String) The unique identifier of the cache.
- `arn` (String) The Amazon Resource Name (ARN) of the cache.
- `endpoint` (String) The endpoint address for connecting to the cache.
- `reader_endpoint` (String) The reader endpoint for read replicas. Only available with Redis cluster mode.
- `status` (String) The current status of the cache. Possible values: `creating`, `available`, `modifying`, `deleting`, `create-failed`.
- `created_at` (String) Timestamp when the cache was created (RFC3339 format).
- `updated_at` (String) Timestamp when the cache was last modified (RFC3339 format).
Nested Blocks
Document complex attributes:
### Nested Schema for `log_delivery_configuration`
Optional configuration for streaming cache logs.
- `destination` (String) The destination for log delivery. Valid values: `cloudwatch-logs`, `kinesis-firehose`.
- `destination_details` (Map of String) Details specific to the destination type.
- `log_format` (String) Log format. Valid values: `text`, `json`. Defaults to `text`.
- `log_type` (String) Type of logs to deliver. Valid values: `slow-log`, `engine-log`.
**Example:**
```terraform
resource "cachecloud_cache" "with_logging" {
name = "cache-with-logs"
engine = "redis"
node_type = "cache.t3.micro"
log_delivery_configuration {
destination = "cloudwatch-logs"
destination_details = {
log_group = "/aws/cachecloud/redis"
}
log_format = "json"
log_type = "slow-log"
}
}
## Additional Information
### Node Types
```markdown
## Node Types
### General Purpose (T3)
Burstable performance instances suitable for development and testing:
- `cache.t3.micro` - 0.5 GB memory
- `cache.t3.small` - 1.4 GB memory
- `cache.t3.medium` - 3.1 GB memory
### Memory Optimized (M5)
Production workloads with consistent performance:
- `cache.m5.large` - 6.4 GB memory
- `cache.m5.xlarge` - 12.9 GB memory
- `cache.m5.2xlarge` - 25.8 GB memory
- `cache.m5.4xlarge` - 51.7 GB memory
### Compute Optimized (C5)
High-performance workloads:
- `cache.c5.large` - 3.3 GB memory
- `cache.c5.xlarge` - 6.7 GB memory
See the [pricing page](https://cachecloud.example.com/pricing) for complete list and regional availability.
Supported Versions
## Supported Versions
### Redis
- **7.0** - Latest version with Redis Functions and ACL improvements
- **6.2** - Redis Streams, ACL improvements
- **6.0** - ACL support, TLS, RESP3
### Memcached
- **1.6** - Latest version with improved performance
- **1.5** - Stable version with TLS support
To check available versions:
```bash
curl https://api.cachecloud.example.com/v1/engines/redis/versions
## Timeouts
Document configurable timeouts:
```markdown
## Timeouts
The `timeouts` block allows you to specify custom timeouts for operations:
```terraform
resource "cachecloud_cache" "example" {
name = "my-cache"
engine = "redis"
node_type = "cache.t3.micro"
timeouts {
create = "45m"
update = "30m"
delete = "45m"
}
}
create(String) Timeout for cache creation. Default:30mupdate(String) Timeout for cache updates. Default:20mdelete(String) Timeout for cache deletion. Default:30m
Note: Large caches may require longer timeouts. Multi-node clusters typically take 20-40 minutes to create.
## Import
### Basic Import
```markdown
## Import
Import existing caches using the cache ID:
```bash
terraform import cachecloud_cache.example cache-123456
After import, review the generated configuration and add any required arguments.
### Complex Import
```markdown
## Import
### Single Cache
Import using the cache ID:
```bash
terraform import cachecloud_cache.example cache-123456
Multi-Region Cache
For caches in specific regions, use region/id format:
terraform import cachecloud_cache.example us-east-1/cache-123456
Cross-Account Cache
For caches in different accounts:
CACHECLOUD_ACCOUNT=123456789012 terraform import cachecloud_cache.example cache-123456
Import Considerations
After import:
- Review Configuration: Verify all attributes match the existing cache
- Add Required Arguments: Some arguments may not be importable
- Check State: Run
terraform planto identify any differences - Update Tags: Imported resources may not include all tags
Example Workflow:
# Import the cache
terraform import cachecloud_cache.prod cache-abc123
# Generate configuration
terraform show -no-color > imported.tf
# Review and adjust
vim imported.tf
# Verify
terraform plan
## Attributes Reference
Document computed attributes:
```markdown
## Attributes Reference
In addition to all arguments above, the following attributes are exported:
- `id` - The unique identifier of the cache (format: `cache-xxxxxxx`)
- `arn` - The Amazon Resource Name (ARN) for use in IAM policies
- `endpoint` - Connection endpoint (format: `cache-name.xxxxxx.cache.example.com:6379`)
- `reader_endpoint` - Read-only endpoint for cluster mode (only available with Redis cluster)
- `status` - Current operational status
- `created_at` - Creation timestamp in RFC3339 format
- `updated_at` - Last modification timestamp
**Example Usage:**
```terraform
output "cache_connection" {
description = "Connection details for the cache"
value = {
endpoint = cachecloud_cache.example.endpoint
port = cachecloud_cache.example.port
}
}
resource "aws_ssm_parameter" "cache_endpoint" {
name = "/app/cache/endpoint"
type = "String"
value = cachecloud_cache.example.endpoint
}
## Complete Example
```markdown
## Complete Example
Full configuration with all common settings:
```terraform
# VPC and networking
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "cache-vpc"
}
}
resource "aws_subnet" "private" {
count = 2
vpc_id = aws_vpc.main.id
cidr_block = "10.0.${count.index + 1}.0/24"
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {
Name = "cache-subnet-${count.index + 1}"
}
}
resource "aws_security_group" "cache" {
name = "cache-sg"
description = "Security group for CacheCloud cache"
vpc_id = aws_vpc.main.id
ingress {
from_port = 6379
to_port = 6379
protocol = "tcp"
cidr_blocks = [aws_vpc.main.cidr_block]
}
}
# Production cache with all features
resource "cachecloud_cache" "production" {
name = "prod-api-cache"
engine = "redis"
version = "7.0"
node_type = "cache.m5.large"
num_nodes = 3
# Network configuration
vpc_id = aws_vpc.main.id
subnet_ids = aws_subnet.private[*].id
security_group_ids = [aws_security_group.cache.id]
# High availability
multi_az_enabled = true
automatic_failover_enabled = true
# Backup configuration
backup_enabled = true
backup_retention_days = 30
backup_window = "03:00-05:00"
# Maintenance
maintenance_window = "mon:04:00-mon:05:00"
# Security
encryption_at_rest_enabled = true
encryption_in_transit_enabled = true
# Monitoring and logging
monitoring_enabled = true
alarm_cpu_threshold = 75
alarm_memory_threshold = 80
log_delivery_configuration {
destination = "cloudwatch-logs"
destination_details = {
log_group = aws_cloudwatch_log_group.cache.name
}
log_format = "json"
log_type = "slow-log"
}
# Parameter group for custom configuration
parameter_group = cachecloud_parameter_group.redis.name
# Tags
tags = {
Environment = "production"
Application = "api"
ManagedBy = "terraform"
CostCenter = "engineering"
}
# Custom timeouts
timeouts {
create = "45m"
update = "30m"
delete = "45m"
}
}
# CloudWatch log group
resource "aws_cloudwatch_log_group" "cache" {
name = "/aws/cachecloud/prod-api-cache"
retention_in_days = 30
tags = {
Environment = "production"
ManagedBy = "terraform"
}
}
# Parameter group with custom settings
resource "cachecloud_parameter_group" "redis" {
name = "prod-redis-params"
family = "redis7"
description = "Custom parameters for production Redis"
parameter {
name = "maxmemory-policy"
value = "allkeys-lru"
}
parameter {
name = "timeout"
value = "300"
}
}
# Outputs for application configuration
output "cache_endpoint" {
description = "Primary endpoint for cache connections"
value = cachecloud_cache.production.endpoint
}
output "cache_reader_endpoint" {
description = "Reader endpoint for read operations"
value = cachecloud_cache.production.reader_endpoint
}
output "cache_arn" {
description = "Cache ARN for IAM policies"
value = cachecloud_cache.production.arn
}
## Best Practices
### 1. Clear Descriptions
```markdown
# ✅ Good: Detailed, actionable description
- `backup_window` (String) Daily time range during which automated backups are created (UTC). Format: `HH:MM-HH:MM` (e.g., `03:00-05:00`). Must be at least 60 minutes and cannot overlap with `maintenance_window`.
# ❌ Bad: Vague description
- `backup_window` (String) Backup time
2. Validation Details
# ✅ Good: Include validation rules
- `name` (String) The name of the cache. Must be 3-63 characters, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens. Must be unique within your account.
# ❌ Bad: No constraints
- `name` (String) Cache name
3. Default Values
# ✅ Good: Document defaults
- `port` (Number) The port number. Redis defaults to `6379`, Memcached to `11211`. Valid range: 1024-65535.
# ❌ Bad: No default information
- `port` (Number) Port number
Key Takeaways
- ✅ Start with clear resource description and use cases
- ✅ Provide basic and complete examples
- ✅ Document all required and optional arguments
- ✅ Include validation rules and constraints
- ✅ Show default values for optional arguments
- ✅ Document computed (read-only) attributes
- ✅ Add timeout configuration when applicable
- ✅ Provide clear import instructions
- ✅ Include complete, working examples
- ✅ Reference related resources and documentation
What’s Next?
Learn how to document data sources with clear usage examples.
Next: Data Source Documentation →
Previous: ← tfplugindocs Tool
Next: Data Source Documentation →
Last updated: June 30, 2026