This guide covers common patterns and best practices for using the Time provider in your infrastructure.
Understanding Time Resources#
The Time provider offers four resource types:
| Resource | Purpose | Updates |
|---|---|---|
| Static | Capture timestamp | Never (unless recreated) |
| Offset | Calculate future/past time | On recreation or trigger |
| Rotating | Automatic rotation | On schedule |
| Sleep | Add delays | On every operation |
Common Patterns#
Secret Rotation Pattern#
Automatically rotate secrets on a schedule:
Certificate Lifecycle Pattern#
Manage certificate creation and expiration:
Staged Deployment Pattern#
Deploy resources in stages with delays:
Expiration Management Pattern#
Track and manage resource expiration:
Best Practices#
Choose the Right Resource#
Use Static when:
- Tracking resource creation time
- Need unchanging timestamp
- Building audit trails
Use Offset when:
- Calculating future dates
- Setting expiration times
- Scheduling one-time events
Use Rotating when:
- Implementing automatic rotation
- Periodic updates needed
- Triggering dependent resources
Use Sleep when:
- Waiting for external systems
- Rate limiting API calls
- Allowing resources to stabilize
Rotation Schedule Guidelines#
| Asset Type | Recommended Rotation | Reason |
|---|---|---|
| Passwords | 90 days | Security compliance |
| API Keys | 30-90 days | Limit exposure window |
| Certificates | 90 days (renew at 60) | Prevent expiration |
| Access Tokens | 24 hours | Minimize breach impact |
| Encryption Keys | 1 year | Balance security/overhead |
Delay Guidelines#
Use minimum necessary delays:
Document why delays exist:
Time Zone Considerations#
All time resources use UTC:
Advanced Patterns#
Multi-Stage Rotation#
Different rotation schedules for different stages:
Coordinated Rotation#
Rotate multiple resources together:
Graceful Updates#
Handle rotation without downtime:
Troubleshooting#
Rotation Not Triggering#
Problem: Resources not recreating on rotation
Solution: Use replaceOnChanges
Unexpected Delays#
Problem: Deployments taking too long
Solution: Review and optimize sleep durations
Time Calculation Errors#
Problem: Incorrect time calculations
Solution: Use consistent time sources
Next Steps#
- Offset Resource - Time calculations
- Rotating Resource - Automatic rotation
- Sleep Resource - Deployment delays
- Static Resource - Timestamp capture