I'm really enjoying working with AWS Code Deploy integrated with Auto Scaling, but am struggling with an issue around reading tags during a scale-in event.
I have setup my Auto Scaling Group to tag any new instances created with a tag name 'Environment'. Then as part of my Code Deploy after-install script I read the tag and use it to conditionally configure my apps. This works perfectly if I deploy a revision to existing instances in an auto scale group. However during a scale-in event it seems that the tags are not assigned to the new EC2 instance before Code Deploy is called from Auto Scaling, so my after-install configuration fails.
Any ideas on a way around this? Can I force the tags to be associated with the EC2 instance earlier in the pipeline?