Add helper script to tag EC2 instances#84
Conversation
WalkthroughAdds a Bash helper that tags the current EC2 instance with a ChangesInstance tagging
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (9 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@helpers/tag-instance.sh`:
- Around line 9-11: The tag generation in tag-instance.sh currently accepts any
input for DAYS, so TAG_VALUE can become an invalid keep-* string. Update the
script to validate the first argument is numeric before constructing TAG_VALUE,
and make sure the logic around DAYS and TAG_VALUE only proceeds with a valid
integer so the helper always produces a keep-N style retention tag.
- Around line 7-15: The tagging script currently falls back to a hardcoded
default region, which can silently target the wrong AWS region. Update the
region handling in tag-instance.sh so it requires an explicit AWS region or
derives it from the instance context instead of using the us-east-2 fallback.
Keep the change localized around the REGION assignment and the aws ec2
create-tags call, and ensure the script fails clearly when no valid region is
available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: a803fe04-efad-443e-9cd1-bf94dcbe2ee4
📒 Files selected for processing (1)
helpers/tag-instance.sh
4aee3e4 to
2becd74
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deploy/Makefile`:
- Around line 86-87: The tag target in the Makefile passes DAYS unquoted to
helpers/tag-instance.sh, which can cause word splitting or shell expansion
before validation. Update the tag recipe so the $(DAYS) value is passed as a
single quoted argument, keeping the command in tag safe even when the variable
contains spaces or special characters.
In `@helpers/tag-instance.sh`:
- Around line 5-6: The tag-instance.sh script currently reads aws-instance-id
directly via cat without checking for a missing or empty file, which leads to a
raw shell failure instead of the standard “no instance found” message. Update
the INSTANCE_ID retrieval logic in the tag flow to mirror the validation used in
deploy/aws-hypervisor/scripts/start.sh by explicitly checking that
INSTANCE_DATA/aws-instance-id exists and is non-empty before reading it, and
emit the repo’s usual user-friendly error if it is absent or blank.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 436efdd2-9cca-48ff-a968-67923843d019
📒 Files selected for processing (2)
deploy/Makefilehelpers/tag-instance.sh
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2becd74 to
5c941ce
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dhensel-rh, vimauro The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary
helpers/tag-instance.shto quickly tag EC2 instances withkeep-Nretention tagsinstance-data/node-0/aws-instance-idautomaticallykeep-2if no argument provided; pass a number for custom days (e.g../helpers/tag-instance.sh 5)Test plan
./helpers/tag-instance.shand verify tag appears on instance./helpers/tag-instance.sh 5and verifykeep-5tag🤖 Generated with Claude Code
Summary by CodeRabbit
tagmake target to run the helper and tag the current instance.tagcommand and how to setDAYS(including default/max behavior).