Skip to content

AWS Snapshot #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matifali opened this issue Apr 23, 2025 · 0 comments
Open

AWS Snapshot #26

matifali opened this issue Apr 23, 2025 · 0 comments

Comments

@matifali
Copy link
Member

matifali commented Apr 23, 2025

Problem

Coder workspaces on AWS currently lack persistent state across workspace stop/start cycles beyond basic EC2 stop functionality. Users need the ability to snapshot their workspace state and resume from selected snapshots.

Proposed Solution

Create a Terraform module that enables AMI-based snapshots of EC2 instances when workspaces are stopped, with user-specified labels and selection options for workspace start.

Implementation Steps

  1. Create AMI snapshots on workspace stop

    • Use aws_ami_from_instance resource triggered by coder_workspace.me.transition == "stop"
    • Tag AMIs with workspace owner, name, label, and creation timestamp
  2. Add user parameters for snapshot control

    • Implement coder_parameter resources for:
      • Enable/disable snapshot functionality
      • Custom snapshot labels
      • Option to start from previous snapshots
  3. Retrieve available snapshots

    • Use aws_ami data source with filters on Coder-specific tags
    • Format snapshot metadata for selection dropdown
  4. Modify instance creation

    • Create a local.ami_id variable that selects user snapshot or default AMI
    • Update aws_instance resource to use this dynamic AMI ID
    • Add lifecycle { ignore_changes = [ami] } to prevent Terraform conflicts
  5. Implement optional cleanup

    • Consider aws_dlm_lifecycle_policy for snapshot retention management
    • Add configuration options for retention periods and counts

Key Considerations

  • Users need IAM permissions for AMI creation/management
  • AMI creation takes time; handle workspace stop gracefully
  • Implement cost control through snapshot cleanup policies
  • Ensure proper tagging for snapshot organization
@Parkreiner Parkreiner transferred this issue from coder/modules May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant