Skip to content

Fix EBS volume tagging for cost tracking#64

Open
cericg wants to merge 1 commit intoJaneliaSciComp:masterfrom
cericg:fix/ebs-volume-tagging
Open

Fix EBS volume tagging for cost tracking#64
cericg wants to merge 1 commit intoJaneliaSciComp:masterfrom
cericg:fix/ebs-volume-tagging

Conversation

@cericg
Copy link

@cericg cericg commented Feb 9, 2026

Problem

AWS Batch ComputeResources.Tags only applies to EC2 instances, not attached
EBS volumes. This causes untagged volumes which breaks cost tracking.

Example:

  • Volume: vol-096ac87ce5ec41606 - No tags
  • Instance: i-09cee327cbc3496ee - Tagged correctly

Solution

Add an EC2 Launch Template with TagSpecifications that explicitly tags both
instance and volume resource types at creation time.

Changes

  1. Add AlignmentLaunchTemplate resource

    • Uses TagSpecifications to tag both instance and volume resource types
  2. Update ComputeAlignmentEnv

    • Add LaunchTemplate reference
    • Remove Tags property (now handled by launch template)

Tags Applied (to both instances AND volumes)

Tag Source
PROJECT config.yml
VERSION config.yml
DEVELOPER $USER env var
STAGE provider.stage

These match the existing stackTags exactly, preserving cost tracking continuity.

Testing

After deployment:

  1. Trigger an alignment job
  2. Check the spawned EC2 instance tags (should be unchanged)
  3. Check the attached EBS volume tags (should now have PROJECT, VERSION, etc.)

References

AWS Batch ComputeResources.Tags only applies to EC2 instances, not
attached EBS volumes. This causes untagged volumes (e.g., vol-096ac87ce5ec41606)
which breaks cost tracking.

Solution: Add an EC2 Launch Template with TagSpecifications that explicitly
tags both 'instance' and 'volume' resource types at creation time.

Changes:
- Add AlignmentLaunchTemplate resource with TagSpecifications
- Update ComputeAlignmentEnv to reference the launch template
- Remove Tags property (now handled by launch template)

Tags applied to both instances and volumes:
- PROJECT, VERSION, DEVELOPER, STAGE (matches existing stackTags)
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

Successfully merging this pull request may close these issues.

1 participant