ALB rules get deleted everyday

0

We are using ALB to route traffic to backend services deployed on EC2. We have added the EC2 as a target group to the ALB. But due to the nature of our applications, we don't have any traffic at night, so we shutdown the EC2 instance everyday. But when we restart them in the morning, we need to add the rules again to the ALB every day.

How to prevent this? (It's okay if the requests simply fail with a gateway error etc. when the EC2 instances are shutdown)

spy16
asked 3 months ago172 views
2 Answers
0

Hello.

we need to add the rules again to the ALB every day.

I don't think it's necessary to add ALB listener rules every day if you just want to stop EC2.
In other words, I think there is no problem just keeping EC2 and the target group connected to the ALB and stopping and starting EC2 as needed.
If you use EventBridge scheduler etc., it is possible to automate the start and stop of EC2.
https://dev.to/aws-builders/easy-setup-for-ec2-stop-jobs-with-amazon-eventbridge-scheduler-4lpg

In some cases, I think it would be easier to manage by setting up EC2's AutoScaling to scale according to a schedule.
https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scheduled-scaling.html

profile picture
EXPERT
answered 3 months ago
0

Thanks for responding!

To clarify, we are actually not doing add/remove of rules everyday. The ALB was created by creating an ingress with class "internet-facing" (This is because we have some services running in k8s as well).. And to that ALB we are adding target-groups pointing to EC2 servers. And we shut down both EC2 and the k8s nodes (just the underlying node pool, the master remains up).

When start everything up in the morning (we are using scheduled lambdas to do this), the k8s ingress works as expected but the rules we have manually added for the EC2 instances go away and we have to manually add them again.

spy16
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions