Skip to content

AWS Snapshot #26

Open
Feature
@matifali

Description

@matifali

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions