1

I am auto starting and stopping the EC2 instances using this solution.

We recently started using Elastic Beanstalk for some of our projects. We have launched following 4 different environments for single project.

  1. Development
  2. Testing
  3. Staging
  4. Production

The Development and Testing environments are used only for 12 hours a day, so we terminate the environment and launch (load saved instance) it daily.

Is it possible to automate this process?

Community
  • 1
  • 1
Amol Chakane
  • 1,501
  • 2
  • 21
  • 43

1 Answers1

2

Your best option should be Time-based scaling. In the console you go to Configuration > Scaling > Time-based scaling for your environment to set up the rules.

Karl Laurentius Roos
  • 4,360
  • 1
  • 33
  • 42
  • Will it load the same/saved (EC2 and RDS) resources? – Amol Chakane May 04 '17 at 04:25
  • @AmolChakane: as long as the service is stateless, yes. If you have an RDS coupled to the environment it will not be taken down, nor will it be restored when you terminate/recreate. I would create the RDS outside of Elastic Beanstalk, take it down and restore it from snapshot using scripts. – Karl Laurentius Roos May 04 '17 at 05:45
  • Can you please guide me to some links regarding this? – Amol Chakane May 04 '17 at 05:52
  • @AmolChakane check out this: http://docs.aws.amazon.com/cli/latest/reference/rds/restore-db-instance-from-db-snapshot.html and http://docs.aws.amazon.com/cli/latest/reference/rds/delete-db-instance.html when you run `delete-db-instance` make sure to give the final snapshot an identifier you can reuse in `restore-db-instance-from-db-snapshot` – Karl Laurentius Roos May 04 '17 at 08:15
  • Using time based scaling only EC2 instances are terminated, ELB will still be running and AWS will charge for that. Does this mean there is no option to terminate the complete environment? – Amol Chakane Sep 05 '17 at 08:22
  • @AmolChakane if that's the case I believe there isn't, you could use something like Terraform to define the environment and completely take it down and recreate it, but that would "live outside" of your EB setup. – Karl Laurentius Roos Sep 06 '17 at 09:17