Make a new EC2 instance on Elastic Beanstalk

0

I deployed my app onto Elastic Beanstalk. I have a few questions related to the EC2 instances:

  • By running en ssh, I understand that I will ssh onto one of the instances. What if there is more than one instance?

  • There is a warning, that changes made to the machine via SSH won't necessarily stick. I have some extra scripts that I run when I deploy (installing extra software in case it isn't there). But... how do I check that my script works? Is there a way to restore the EC2 instance to its initial state without launching a 'Rebuild environment'? At least I can test if my hook works

  • In fact, if I have 2 or more EC2 instances, how do I know which one I ssh'd into? Or, do they share the same file system? Or... how does it actually all work, in terms of respawning, recreating, etc?

asked 4 years ago309 views
2 Answers
0

Hi !

With eb ssh, you can specify the instance ID with the -i option:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-ssh.html

If you want to always run extra scripts on your starting instances, I recommend you one of those four options:

  1. Use Docker
    https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.html
    https://docker.io
    https://docker-curriculum.com

  2. Create your AMI
    https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html

  3. Use a custom platform
    https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platforms.html

  4. Use .ebextensions config files.
    It can give you advanced features: for example, if there are some scripts that you want to run only on one instance, you can use the leader_only command in a .ebextensions file.
    https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html

Finally, for how the auto-scaling works, there are different strategies possible you can choose from, you can see how Auto-Scaling Groups do it here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.as.html

I hope this will help you in your journey with Elastic Beanstalk.

Have a good day,

Haks

answered 4 years ago
0

Thanks for the help. For SSH, I discovered that if you have more than one EC running, eb ssh actually asks you which one you want to connect to.

I am confused by the rest of your answer. I had already stated that I have extra scripts running -- I didn't mention that they were provided by ebextensions.

As for the "how to see if my script works", all I did was go to the EC2 console and forcefully terminate the two running instances. This forced Amazon to make new ones -- from there, I could see that everything did work, and my custom scripts actually ran.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions