AWS AMI Snapshot Module for Persistent Workspace State #219
+473
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements AMI-based snapshots for Coder workspaces on AWS, enabling persistent state across workspace stop/start cycles. Users can now create snapshots of their workspace state when stopping and restore from selected snapshots when starting workspaces.
Solves GitHub Issue #26 - AWS Snapshot functionality for persistent workspace state.
Type of Change
Module Information
Path:
registry/mavrickrishi/modules/aws-ami-snapshot
New version:
v1.0.0
Breaking change: [ ] Yes [x] No
Implementation Details
All Requirements from Issue #26 Implemented:
✅ Requirement 1: Create AMI snapshots on workspace stop
aws_ami_from_instance
resource triggered bycoder_workspace.me.transition == "stop"
✅ Requirement 2: Tag AMIs with workspace metadata
✅ Requirement 3: User parameters for snapshot control
enable_snapshots
- Toggle snapshot creation (default: true)snapshot_label
- Custom label for snapshots (optional)use_previous_snapshot
- Dropdown to select from available snapshots✅ Requirement 4: Retrieve available snapshots
aws_ami_ids
data source with Coder-specific tag filters✅ Requirement 5: Modify instance creation
local.ami_id
variable selects user snapshot or default AMIlifecycle { ignore_changes = [ami] }
prevents Terraform conflicts✅ Requirement 6: Optional cleanup
aws_dlm_lifecycle_policy
for snapshot retention management✅ Requirement 7: Key considerations
Testing & Validation
Comprehensive Test Suite
Created comprehensive test script that validates ALL requirements from issue #26:
🔧 Comprehensive Test Script (Click to expand)
Test Results Summary
bun test
- validates module structure)bun run fmt
- all files properly formatted)terraform validate
- configuration is valid)Module Structure
Namespace Structure
Key Features Implemented
🎯 Core Functionality:
🔧 Technical Implementation:
ignore_changes = [ami]
🎛️ User Experience:
💰 Cost Management:
Security & IAM
Required IAM Permissions:
Usage Example
Related Issues
Video Demonstration
Screencast.from.2025-07-12.15-57-09.mp4
Screencast.from.2025-07-12.15-59-23.mp4