AWS AutoScalingGroup created by ElasticBeanstalk

I am trying to set custom scaling policies for our ElasticBeanstalk environments. As part of this build EB builds an ASG with a default policy attached based off of a single metric.

My issue is i cant find a way to access that Scaling Policy from Terraform to either bring it in as a data source or even just bring in the CloudWatch alarm and modify it or as an attribute of Beanstalk.

The only work arounds i can think of is importing the policy as a terraform resource or disabling the EB generated policy and making new ones in terraform but i really dont want to have a manual step to this automated build.

Ive looked through all the AWS Provider documentation for Beanstalk and ASGs and i dont see a way to use an existing policy as a datasource.

Hi @jeremiah.reagan,

I must admit I’m not deeply familiar with Elastic Beanstalk, but this sounds like a situation that comes up a few places in the AWS API where one object you are directly managing is itself responsible for creating and managing objects in other downstream AWS services.

In such cases it’s generally best to leave Terraform unaware of that other object and manage it only indirectly through the object you are directly managing. Terraform generally expects that any object it’s managing is exclusively managed by Terraform, and so if you try to tell Terraform that it’s also responsible for this object then you’ll probably see weird behavior as Terraform and Elastic Beanstalk both fight each other trying to configure the same object in different ways.

If Elastic Beanstalk itself doesn’t offer any way to customize the object that it’s creating on your behalf then perhaps it’s possible to disable (or just ignore) that object and then declaring a separate autoscaling group directly yourself.

However, I think I remember Elastic Beanstalk being a kinda “hands off” system which is intended to manage a whole bunch of EC2 stuff (and other stuff) on your behalf, so I don’t know if that’s actually possible in practice; it would presumably require that Elastic Beanstalk export the name of the launch configuration it’s creating so that you can pass it into the configuration of your own autoscaling group, and I don’t see any attribute for that in any of the Elastic Beanstalk resource types.