1

I’ve configured CD using CodePipeline & CodeDeploy.

  • EC2 instances in Autoscaling Group (3 instances)
  • Application Load Balancer with configured health check
  • UWSGI applications on EC2 Instances

CodeDeploy Deployment Group Configuration:

  • Assigned Application Load Balancer
  • Targets Autoscaling Group (with attached Application Load Balancer).
  • In-place deployment.

Then I have appspec, that has following hooks:

hooks: BeforeInstall: - location: scripts/clean_instance.sh timeout: 120 runas: root AfterInstall: - location: scripts/install_python_dependencies.sh timeout: 300 runas: project_user - location: scripts/compile_translations.sh timeout: 300 runas: project_user ApplicationStart: - location: scripts/start_application.sh timeout: 120 runas: project_user ApplicationStop: - location: scripts/stop_application.sh timeout: 120 runas: project_user 

When deployment is progressing users receive 5xx errors and it feels like if instances are not taken out from ALB. The documentation here https://docs.aws.amazon.com/en_us/codedeploy/latest/userguide/integrations-aws-elastic-load-balancing.html states, that

When you use an Elastic Load Balancing load balancer with an in-place deployment, instances in a deployment group are deregistered from a load balancer, updated with the latest application revision, and then reregistered with the load balancer as part of the same deployment group after the deployment is successful.

And I can see actual BlockTraffic and AllowTraffic events in deployment console. But then I’ve found this repository https://github.com/aws-samples/aws-codedeploy-samples/tree/master/load-balancing/elb-v2, which states that some custom scripts have to be executed to deregister instances from load balancer.

Should I actually use those scripts? If yes, then why documentation states, that ALB is not routing traffic on instances that are in the deployment process? If not, then why users encounter those 5xx errors while we deploy application?

1
  • This question is very very detailed and specific, and appears to describe a bug in AWS. Can you reduce it to a minimal reproducible test case? You could then report that to Amazon AWS support. It's unlikely that anyone other than they can give a definitive answer as to "why", let alone fix it for you. Also, the title does not really summarise your question. Perhaps "Why does ELB (appear to) route traffic to unstable instances during in-place deployment?" would be a better title? Commented Aug 31, 2019 at 20:07

1 Answer 1

0

https://docs.aws.amazon.com/en_us/codedeploy/latest/userguide/integrations-aws-elastic-load-balancing.html states, that...

This is just an overview how it supposed to work

which states that some custom scripts have to be executed to deregister instances from load balancer.

Since it's in-place it doesn't automatically do anything to an instance unless you specify specifically in your AppSpec.

This script to deregister is what you need to start from and then update the app with the latest revision and then this script to register

This should work if you have OneAtATime deploy conf and if you have at least 2 instances.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.