I am deploying one of ECS Spring Boot services from my workplace AWS account, in my own AWS account. I am using identical settings for cluster, service, target group, autoscaling group. I recreated all components of this ECS service in my AWS account, and I don't think that I missed anything.
Both are running directly on EC2 instances through autoscaling groups (i.e. not Fargate).
The only difference is that the service in the workplace account has health check grace period = 0 in service settings, and the ECS task spins up very quickly, and is marked "healthy" in target group's dashboard, while in case of my account, this same app requires at least 300 seconds of grace period, otherwise the task is marked "unhealthy" and eventually terminates with message STOPPED (Task failed ELB health checks in (target-group arn:..., spinning up a new task, which terminates as well and so on.
Even with 300 seconds grace period, the task becomes "unhealthy" for a minute, and only then moves to "healthy" state.
Anyone knows why this happens? Why in case of my AWS account, my app needs 300 seconds of grace period to start in "healthy" state?
PS. In both autoscaling group settings, in "health checks" section, health check type is marked as "EC2" and health check grace period is zero (if that matters)
PS2. One more difference, the autoscaling group has desired=3, min=1, max=10 in workplace account, and desired=1, min=0, max=1 in my account