1
votes

I have a auto-scaling-group setup. When there are no running instances per that group and my application deploys, the auto-scaling-group will spin up an instance and deploy. Fantastic. ... well sorta...

If there are more than one instances in that auto-scaling-group, then my scripts might point to one instance or another.

How do I deploy to a specific instance without having to setup all the CodeDeploy application, deployment-group, send a new revision, yada, yada, yada...

Or, do you have to take all of those steps each time? How then do you track your deployments? Surely there's a better way to this?

Ideally, I would like to create an Instance based on an AMI, associate that instance with my auto-scaling-group, then deploy specifically to that instance. But I can't create-deployment to an instance, only to a deployment-group.

This is maddening.

1
Are you tagging your ec2 instances? If so then you could try setting the deployment group to target the desired Instance with a unique tag - lasec0203
Yep. I even removed the scaling group and just did what you mentioned. Now I'm having deployment problems. Works once out of every 15 times with the new instance. Not a thing wrong, no logs. Just runs for 10 minutes and fails. HEALTH_CONSTRAINTS is about as clear as mud. I've read their troubleshooting 5X to make sure I didn't miss anything. I get the same results doing it manually from the console. No clue why. I can even create a brand new instance, application, deployment group and deploy... Same results. Works every once in a while. Frustrated. - J-Roel
To see the deployment log: docs.aws.amazon.com/codedeploy/latest/userguide/… on Linux you could tail that file and get real-time feedback while deployment is running with tail -f [path to file], not sure if that's possible possible on windows. Hopefully you can see where exactly your deployment is failing at - lasec0203
Got it. On windows. I had to log into the instance and goto: C:\ProgramData\Amazon\CodeDeploy\log. It is a Missing Credentials error. So I'll have setup my run-instances command to setup a role profile when it starts up so I have correct credentials. Must be the missing piece between a launch configuration and just running that instance from the CLI. - J-Roel
@lasec0203 Thank you for your help! - J-Roel

1 Answers

0
votes

The problem you describe can easily be solved with HashiCorp Packer. With a packerfile you can describe the way your application is supposed to be deployed to an instance. This instance is then snapshotted and turned into an available AMI. After which you can update your target group for your autoscaling group with a new AMI.

Documentation for Packer can be found here: