Customizing an Elastic Beanstalk AMI - amazon-web-services

I need to use on Elastic Beanstalk a Java application written for Glassfish server.
Beacuse of Amazon doesn't let me choose an AMI with Glassfish, I choosed one with Tomcat and i modified my application to work properly on Tomcat.
Now, I've seen I also needed to use a Sun JDK, while by default Elastic Beanstalk AMI comes with openjdk. I googled a lot, finding some (not so many resources) interesting posts like this answer on StackOverflow
What I can't understand is this part of the answer:
Create your custom AMI from a running instance of Amazon's beanstalk
AMI that you manually launch from EC2, NOT one that was launched from
starting your application through beanstalk.
So, my question is: does anyone how to use a custom AMI with Glassfish on Elastic Beanstalk?
If it's not possible, can someone explain me how to create the custom AMI?
Thanks,
Andrea

That answer just means "Don't start a beanstalk application and cut an AMI directly from one of those instances. Instead, launch an instance based on the beanstalk AMIs (which are available in the public AMI listing)." I.e., use one of these; note there are 84 of them:
Cut your own private AMI when you're done configuring that instance, and specify it in your beanstalk environment.

I personally found the selected answer confusing for me to follow, maybe because I am still climbing up the AWS learning curve. Maybe this answer will help other newbies. Having just figured out how to successfully launch an Elastic Beanstalk instance with my own custom AMI, what I believe this quote is saying, is to do the following totally non-obvious steps which just worked for me:
Go to the EC2 services (not Elastic Beanstalk services) and launch an instance based on the Elastic Beanstalk AMI that you would like to use as a starting point for your custom AMI. You will throw this away in a minute.
Select the instance and choose "Create Image / EBS AMI". Once created, you can delete the temporary EC2 instance you created. It's only purpose was to create the custom AMI.
Now go to Elastic Beanstalk services and edit your configuration to reference your custom AMI.

#Danger It would speed up the scaling up process.
I'm using a docker app on EB but "docker pull" from Docker Hub is so slow so when all instances are unhealthy my site would be down in 15-30 minutes. Create a customize AMI and pull a base Docker image will save time.

Related

Building an AWS Elastic Beanstalk platform from an AMI

I have configured an EC2 server with a specific set of packages and created a custom AMI from the instance which is setup just how I like it. I would like to use Elastic Beanstalk to generate a new instance with the same setup. Is that possible? When I am asked to select a platform in EBS my custom AMIs are not available to me. I cannot "apply" an AMI to an existing EC2 created by EBS.
I would like to know how Elastic Beanstalk makes use of custom AMIs. I cannot find a clear answer in the docs.
By default Elastic Beanstalk only provide Amazon Linux in case Linux OS. You can use your custom AMI with ElasticBeanstalk. In the AMI selection stage paste the AMI-ID of your custom AMI and you are good to go.

Stop AWS Elastic Beanstalk from creating new instance

Is it possible to prevent Amazon Elastic Beanstalk from dropping an instance and creating a new one on its own, like for it to ask for approval first. I run a redis instance locally because elasticache is quite expensive and I dont want to have to keep installing and starting redis every time elastic beanstalk drops the instance and starts a new one. Is it possible to make sure it keeps a specific instance of EC2?
Elastic Beanstalk is meant for scaling web applications, so I'm not sure it's the right tool here.
If you are just looking to run a single instance with a manual install of redis at low cost, then launching an EC2 instance directly (rather than using Elastic Beanstalk) may be more appropriate?
You would of course then need to bear in mind that the EC2 would not automatically recover in the event of a problem, but it sounds like you don't have that currently anyway.

Enterprise Apps with Docker and Elastic Beanstalk

I'm new to Docker and EB but not AWS. I've worked in environments where dedicated tenancy is a requirement, whether due to HIPPA or some other data protection requirements.
So far as I can tell, in order to deploy a Docker image, you must use Beanstalk, which means you aren't able to have a dedicated tenancy. I found this forum question that says if you create a VPC, you can have a dedicated Beanstalk. Is this correct? If so, will it work with Docker? If so any guides would be helpful.
Have you looked at Amazon's ECS service? It is a Docker container service that doesn't use Elastic Beanstalk.
You can also install Docker on any EC2 instance.
If you use a VPC then you can set the default tenancy to dedicated, which will result in dedicated tenancy instances being created by Beanstalk. You should be using a VPC already if you are concerned with HIPAA compliance, or if you want access to pretty much any of the new features released by Amazon in the last year.
Also, EBS stands for Elastic Block Storage, Elastic Beanstalk is usually abbreviated EB.
If you'd like to venture a bit more, you can also use other tools like
Kubernetes
Apache Mesos
RancherOS
For a more comprehensive list of Docker/Container related projects you can see this post:
How to scale Docker containers in production
You can run them all in EC2 with VPC, also using dedicated tenancy if you'd like to.

AWS EC2 and Elastic Beanstalk

I am new to AWS and the question may seem very basic. However I need to see if I can find a solution to this.
I have created and launched an EC2 instance first and then created an Elastic Beanstalk instance with a sample application deployed on it. By default, the Elastic Beanstalk attaches "Default Environment" to this instance and I find no way to change this to my EC2 instance. How can I attach my EC2 instance (that I created earlier) to this Elastic Beanstalk instance? I am using Amazon Free Tier to learn.
Thanks a lot for your time and patience.
You cannot add an existing instance into an Elastic Beanstalk configuration.
Under the hood Elastic beanstalk uses Containers and a ton of configuration hooks, files, etc.
An instance is not the same and cannot even be guaranteed to be of matching types (perhaps the instance is CentOS and the Container runs on an ubuntu host).
It's simply not possible.

Launching C applications on an AMI's startup in AWS Elastic Beanstalk

Does anyone know if it's possible to make my own AMI's for use in the AWS Elastic Beanstalk? The AMI would simply have a C program that executes when the instance starts.
Yes, it is possible. Simply spin an EC2 instance up based on their stock beanstalk AMIs, which I believe Amazon makes available in the community AMI list, make your changes, cut an AMI off that fixed instance, and use that newest AMI id in your beanstalk application's configuration.
There is nothing abnormal or unusual about this.
Alternatively, you can use UserData and CloudInit to download and launch the application on instantiation. This would avoid having to change the stock AMI.