1 — Elastic Beanstalk and EC2
Elastic Beanstalk is a Platform-as-a-Service (PaaS) that automates the deployment of your application.
When you deploy, EB creates and manages EC2 instances for you. You normally don’t have to manually manage those EC2 instances — EB handles scaling, health monitoring, updates, etc.
But:
- You can access those instances directly via SSH if you enable it.
- You can customize instances by modifying configuration files or using
.ebextensions
, etc. - You should avoid making manual changes that you want to persist, because EB might replace the instance.
2 — Why you might need EC2 access here
Elastic Beanstalk launches instances and runs the installation/configuration during provisioning.
If installation takes a long time, you can use Amazon Machine Images (AMIs) to skip the installation step.
That’s where EC2 access comes in:
- You launch an instance.
- Install all the dependencies and dynamic/static files manually.
- Create a custom AMI from that instance.
- Configure Elastic Beanstalk to use this custom AMI for its instances.
This means when EB launches a new instance, it starts from your prebuilt AMI, and provisioning time is dramatically reduced.
3 — How to do this safely
Elastic Beanstalk instances are ephemeral — EB can terminate them for scaling or deployment.
That’s why you don’t manually log in to production instances for permanent changes — instead, you create a custom AMI or use EB configuration files to bake changes in.
Two common approaches:
- Custom AMI & user data of EC2
- Access EC2 instances.
- Install everything.
- Create an AMI.
- Configure EB to use that AMI.
- Result: New instances start ready to run.
- Configuration Scripts
- Use
.ebextensions
or EB configuration to install dependencies and files during deployment. - But this may still take time if installation is long.
4 — Why EB normally hides EC2 management
Elastic Beanstalk abstracts EC2 management to make deployments simpler — you focus on code, not infrastructure.
That’s why direct EC2 access feels “restricted” — it’s intentionally discouraged for normal workflow, but possible and sometimes necessary (like creating a custom AMI).
✅ Key takeaway:
You can access and manage Elastic Beanstalk EC2 instances (via SSH), but changes won’t persist unless baked into a custom AMI or configuration. For your use case, the solution is to create a custom AMI so EB launches new instances in under 2 minutes.
Top comments (0)