Simplify Adhoc#start_inactive_instance logic #36571
Merged
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.
When starting a stopped EC2 instance its public IP address changes, because IPv4 addresses are not retained for inactive network interfaces. In order for an
adhoc
instance (which does not use a CDN or load-balancer) to continue serving public traffic, its DNS entries need to be updated to point to the new IP addresses when the instance is started again.Previously, the
adhoc:start_inactive_instance
rake task would call#start
on the EC2 instance, then manually update the DNS entries linked from the CloudFormation stack viachange_resource_record_sets
. This had an issue where it would prevent the DNS records from deleting when the stack is deleted, because theAWS::Route53::RecordSetGroup
CloudFormation resources would become out of sync with the actual entries. The issue prevents adhoc stacks from being deleted and re-created due to the left-over DNS entry.This PR fixes the issue and simplifies the
start_inactive_instance
implementation by modifying theUserData
property of the daemon instance and updating the stack. This triggers a reboot of the EC2 instance (causing it to start), and also triggers theRecordSetGroup
resources to be updated to the instance's new values.