I have one autoscaling group that is part of AWS CodeDeploy Blue-Green deployment. I have one custom metric for memory utilization attached to this autoscaling group as a dynamic scaling policy. I created this custom metric policy following the AWS documentation (https://aws.amazon.com/blogs/mt/create-amazon-ec2-auto-scaling-policy-memory-utilization-metric-linux/).
After every deployment, my Autoscaling Group name changes with addition to the name as the codedeploy deployment ID.
I am facing a lot of issues because of that. After the deployment, my scaling policy doesn't work as it is created with an autoscaling group name which is changed on each deployment. Furthermore, I have other alarms created with metrics like CPU Utilization, which stop working after the Blue-Green deployment.
I have searched a lot but couldn't find any referenced document to fix this issue. Can someone please help me how it would be possible to automatically change the names in alarms and scaling policy as autoscaling group name changes with new deployment?