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
已提問 4 個月前檢視次數 185 次
2 個答案
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
專家
已回答 4 個月前
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
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南