AWS Beanstalk with working app fails to deploy app to new ec2 when current one is terminated

373 views Asked by At

I have a new beanstalk that is a migration of an old one running an app under php5.6 platform on Amazon AMI Linux. The new beanstalk is running php7.3 on Amazon Linux2. I have worked through all the migration issues and the app is running correctly on my new beanstalk. I have a load-balancer (classic) and I run autoscaling with the max and min instance settings both set to 1.

The problem occurs when I terminate the ec2. The autoscaling is creating a new ec2 but it is't deploying the application to it.

Does anyone know why this might be, or where I can look to try and debug the issue?

1

There are 1 answers

0
Nick Weavers On

What worked for me was to remove the old .ebextension config files related to cwlogs, and add the line

awslogs: []

to my config that does

packages:
  yum:

then create a new conf file as follows

files:
  "/tmp/start_aws_cloudwatch_service.sh":
    content: |
      #!/bin/sh
      systemctl start awslogsd
      systemctl status awslogsd
      systemctl enable awslogsd.service
      exit $?
    mode  : "000755"
    owner : root
    group : root
commands:    
  start_aws_cloudwatch_service:
    cwd: /tmp
    command: bash /tmp/start_aws_cloudwatch_service.sh   

After this I could see that the service was up and running

$ systemctl status awslogsd
● awslogsd.service - awslogs daemon
   Loaded: loaded (/usr/lib/systemd/system/awslogsd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-10-14 14:08:19 UTC; 34min ago
 Main PID: 4029 (aws)
   CGroup: /system.slice/awslogsd.service
           └─4029 /usr/bin/python2 -s /usr/bin/aws logs push --config-file /etc/awslogs/awslogs.conf --additional-configs-dir /etc/awslogs/c...

Oct 14 14:08:19 ip-xxx-xxx-30-7.eu-west-1.compute.internal systemd[1]: Started awslogs daemon.
Oct 14 14:08:19 ip-xxx-xxx-30-7.eu-west-1.compute.internal systemd[1]: Starting awslogs daemon...

See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html