I'm trying to set up my Elastic Beanstalk environment to have an auto scaling group with a creation and update policy that waits for a signal from any new instances. Unfortunately I'm having issues getting this to work, and I believe it's because of a circular dependency. I have one config file in .ebextensions with the auto scaling configuration:
Resources:
AWSEBAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
HealthCheckType: ELB
HealthCheckGracePeriod: 300
UpdatePolicy:
ResourceSignal:
Timeout: PT30M
CreationPolicy:
ResourceSignal:
Timeout: PT30M
I have another configuration file which is supposed to run the cfn-signal script which will allow the auto scaling group to finish creating or updating:
commands:
"01cfn-bootstrap-update":
command: yum update -y aws-cfn-bootstrap
"02cfn-signal":
env:
stackName:
Ref: AWS::StackName
region:
Ref: AWS::Region
command: /opt/aws/bin/cfn-signal -e $? --stack ${stackName} --resource AWSEBAutoScalingGroup --region ${region}
When I create the environment, the auto scaling group is created and waits for the signal. However, the signal is never sent by the instance. I ssh'd into the instance and, looking at the logs, I saw that the cfn-signal command (or any commands in .ebextensions) was not being executed.
I believe that this is because Elastic Beanstalk processes the .ebextensions one at a time, so it is not ever processing the cfn-signal config file until after the auto scaling config file is completed. Because this resource waits for that same signal, it never completes and the signal command never runs. I have also tried removing the auto scaling config file completely, and the cfn-signal command was able to run in that case (although it failed because the auto scaling group was not waiting for the signal). I have also tried renaming the files so that the cfn-signal file is before the auto scaling config file alphabetically, but that didn't make any difference. Is my understanding correct, that there is a circular dependency here? Is there any work around for it?