localstack-state
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseState Management
状态管理
Save, load, and manage LocalStack state for reproducible development environments and state snapshots.
保存、加载并管理LocalStack状态,以实现可复现的开发环境和状态快照。
Capabilities
功能特性
- Export and import state locally to files
- Save and load state to/from Cloud Pods (remote storage)
- Share state across teams via Cloud Pods
- Enable persistent state across container restarts
- 本地导出和导入状态到文件
- 将状态保存到Cloud Pods(远程存储)或从其中加载
- 通过Cloud Pods在团队间共享状态
- 实现容器重启后的状态持久化
Local Snapshots (state export/import)
本地快照(状态导出/导入)
Local snapshots allow you to export LocalStack state to files and import them back. This works without requiring a Pro subscription.
本地快照允许您将LocalStack状态导出到文件并重新导入。此功能无需Pro订阅即可使用。
Export State
导出状态
bash
undefinedbash
undefinedExport current state to a local file
将当前状态导出到本地文件
localstack state export my-state.zip
localstack state export my-state.zip
Export to a specific path
导出到指定路径
localstack state export /path/to/backup/state.zip
undefinedlocalstack state export /path/to/backup/state.zip
undefinedImport State
导入状态
bash
undefinedbash
undefinedImport state from a local file
从本地文件导入状态
localstack state import my-state.zip
localstack state import my-state.zip
Import from a specific path
从指定路径导入状态
localstack state import /path/to/backup/state.zip
undefinedlocalstack state import /path/to/backup/state.zip
undefinedUse Cases for Local Snapshots
本地快照的使用场景
- Backup/restore: Save state before destructive operations
- CI/CD pipelines: Commit state files to version control for reproducible tests
- Offline workflows: Work with state files without cloud connectivity
- Quick snapshots: Fast local save/restore during development
- 备份/恢复:在执行破坏性操作前保存状态
- CI/CD流水线:将状态文件提交到版本控制,以实现可复现的测试
- 离线工作流:无需云连接即可使用状态文件
- 快速快照:开发过程中快速进行本地保存/恢复
Cloud Pods (pod save/load)
Cloud Pods(Pod保存/加载)
Cloud Pods store state in LocalStack's cloud platform, enabling team collaboration and remote state management.
Cloud Pods将状态存储在LocalStack的云平台中,支持团队协作和远程状态管理。
Prerequisites
前提条件
Cloud Pods require a LocalStack Pro subscription and auth token:
bash
export LOCALSTACK_AUTH_TOKEN=<your-token>使用Cloud Pods需要LocalStack Pro订阅和认证令牌:
bash
export LOCALSTACK_AUTH_TOKEN=<your-token>Save to Cloud Pod
保存到Cloud Pod
bash
undefinedbash
undefinedSave current state to a Cloud Pod
将当前状态保存到Cloud Pod
localstack pod save my-pod-name
localstack pod save my-pod-name
Save with a message
附带说明信息保存
localstack pod save my-pod-name --message "Initial setup with S3 and DynamoDB"
undefinedlocalstack pod save my-pod-name --message "Initial setup with S3 and DynamoDB"
undefinedLoad from Cloud Pod
从Cloud Pod加载
bash
undefinedbash
undefinedLoad state from a Cloud Pod
从Cloud Pod加载状态
localstack pod load my-pod-name
localstack pod load my-pod-name
Load and merge with existing state
加载并与现有状态合并
localstack pod load my-pod-name --merge
undefinedlocalstack pod load my-pod-name --merge
undefinedList Cloud Pods
列出Cloud Pods
bash
undefinedbash
undefinedList all available Cloud Pods
列出所有可用的Cloud Pods
localstack pod list
undefinedlocalstack pod list
undefinedDelete Cloud Pods
删除Cloud Pods
bash
undefinedbash
undefinedDelete a Cloud Pod
删除一个Cloud Pod
localstack pod delete my-pod-name
undefinedlocalstack pod delete my-pod-name
undefinedInspect Cloud Pods
查看Cloud Pods详情
bash
undefinedbash
undefinedView Cloud Pod details
查看Cloud Pod详情
localstack pod inspect my-pod-name
undefinedlocalstack pod inspect my-pod-name
undefinedUse Cases for Cloud Pods
Cloud Pods的使用场景
- Team collaboration: Share consistent development environments across team members
- Demo environments: Prepare and share demo-ready states
- Cross-machine development: Access the same state from different machines
- 团队协作:在团队成员间共享一致的开发环境
- 演示环境:准备并分享可直接用于演示的状态
- 跨机器开发:从不同机器访问相同的状态
Local Persistence
本地持久化
For automatic persistence across LocalStack restarts (without explicit export/import):
bash
undefined若要在LocalStack重启后自动保持状态(无需显式导出/导入):
bash
undefinedEnable local persistence
启用本地持久化
PERSISTENCE=1 localstack start -d
PERSISTENCE=1 localstack start -d
State is saved to .localstack/ directory
状态将保存到.localstack/目录
Survives container restarts
容器重启后仍会保留
undefinedundefinedComparison
对比
| Feature | Local Snapshots (export/import) | Cloud Pods (save/load) |
|---|---|---|
| Storage | Local files | LocalStack cloud |
| Pro required | No | Yes |
| Team sharing | Manual file sharing | Built-in |
| Version control | Can commit files | Cloud-managed |
| Offline use | Yes | No |
| 特性 | 本地快照(导出/导入) | Cloud Pods(保存/加载) |
|---|---|---|
| 存储位置 | 本地文件 | LocalStack云端 |
| 是否需要Pro订阅 | 否 | 是 |
| 团队共享 | 手动文件共享 | 内置支持 |
| 版本控制 | 可提交文件到版本控制 | 云端管理 |
| 离线使用 | 是 | 否 |
Best Practices
最佳实践
- Use for local development and CI/CD pipelines
state export/import - Use Cloud Pods for team collaboration and shared environments
- Use descriptive names that indicate the state contents
- Enable for simple state retention across restarts
PERSISTENCE=1
- 使用进行本地开发和CI/CD流水线
state export/import - 使用Cloud Pods进行团队协作和共享环境
- 使用能体现状态内容的描述性名称
- 启用以在重启后简单保留状态
PERSISTENCE=1