I'm trying to deploy an application to AWS that requires some extra software installed on the server. To create the custom image, I followed the instructions I found here and here to start an EC2 instance and install my software. I then created a snapshot before terminating the instance.
Now my question: How do get beanstalk to use my snapshot when creating an application? When I try to create an application, only the 7 basic AMIs are available for 'container type'.
From personal expirence I can say that most documentation on elastic beanstalk customization is outdated. What about using of custom ami, you need to know the actual version of the elastic beanstalk anyway installs beanstalk scripts and performs configuration on new instance bootstrap, so if you use custom ami it also happens. Base on this I would recommend to use custom ami when you need to have some OS level customizations.
If you need to install some additional software or change something I would recommend to use approach described here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
Good example described here:
http://www.hudku.com/blog/innocuous-looking-evil-devil/
Also you can find a lot of examples on github if you try to find keyword: .ebextentions
Fire up your environment configuration, and then switch to the custom AMI you've registered, in the Environment Settings. If possible, save a Configuration Template for further usage.
Related
I have a working Elastic Beanstalk environment(PHP 7.3).
The ec2 uses Amazon linux2.
I now have to run some userdata ( yum install ... , curl ...) on these ec2 before they start.
Is this possible ?
I wish userdata was included in Launch configuration.
Can any provide some guidance here.
Just as an FYI, I am using cloudformation.
Thanks !
You can't directly modify UserData that EB is using on its instances, as the UserData is constructed by the EB service based on your setup. You can access it and view it, but can't modify from the CloudFormation level.
There are few options that could potentially server your purpose, depending on your exact needs:
User Resources section in your .ebextensions to add CloudFormation code to the template that EB is generating.
Create custom AMI to use in place of those provided by EB. This way you can set them up and fine tune to your requirements.
Use .ebextensions and platform hooks to install extra software or curl webservices you need.
Hope this helps.
I am trying to use AWS Beanstalk to implement the following:
Create a "baseline" AMI template which has all the "supporting" sofware which my application needs.
Use this template as the base image for a .NET MVC Beanstalk applications.
First I got a "Windows_Server-2019-English-Full-Base-2019.10.09" image from Community AMI library and created an EC2 instance from is. I then went ahead and installed all the needed software, stopped the instance and created a launch template from it. Then I tried various ways to bootstrap a simple sample .NET MVC application with the AMI of the launch template which I have just created. Could not get this work, was getting some cryptic post command errors all over the place.
I then went back to the Community AMI library and searched for another baseline to use. I found the "aws-elasticbeanstalk-amzn-2019.08.16.x86_64-WindowsServer2012R2Core-V2-hvm-201908232334" base image. I created a EC2 instance from this, stopped it and created the launch template. I was finally successful in starting my sample .NET MVC app using this baseline template. At this point, I thought, let me RDP into the EC2 instance (the source of the launch template) and install all the needed software. When I did this, this looks like it is some stripped down version of windows because only one windows opened and its the command prompt (there is no explorer.exe).
My question is:
Is my approach correct for something like this?
Should I just try to install all the software thats needed as part of the deployment? I think this might be possible, but it would be a lot of pain ...
How do I know which AMI baselines I can use with elasticbeanstalk? I cant find any documentation about that these images were build for (other then the image name)
What are the "NET Beanstalk Cfn Container" and ".NET Beanstalk HostManager" images?
Guessing this statement applies:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html
Note:
AMIs that aren't managed by Elastic Beanstalk aren't supported for Windows Server-based Elastic Beanstalk platforms.
Probably why the EB managed AMI "aws-elasticbeanstalk-amzn-2019.08.16.x86_64-WindowsServer2012R2Core-V2-hvm-201908232334" worked but the community AMI didn't. Assume EB requires a bunch of software installed that isn't present in non-EB managed AMIs.
So, question is in title.
By default it deploys 1.5.2 version.
Is it possible to downgrade?
No its not, Amazon Elastic Search is a managed service, in exchange for them taking on the responsibility of managing everything for you, you give up some control. Picking the version you want to run is one of those things.
You can of course spin up your own EC2 instances and install whatever version you would like to run instead.
I want to use an AMI that have not been created from a snapshot. The AMI was created using a virtual machine and then I used CLI tools to create the instance and the AMI.
This instance have installed cloud-init. Could I use this AMI to create instances using cloudformation?
Do I need to install more software to use that service?
Thanks!
Yes, definitely, that is a very common use case:
Amazon Web Services (AWS) publishes many Amazon Machine Images (AMIs)
that contain common software configurations for public use. In
addition, the AWS developer community has published many custom AMIs.
You can also create your own custom AMIs so that you can quickly and
easily start new instances that have everything you need for your
application. For example, if your application is a website or a web
service, your AMI could include a web server, the associated static
content, and the code for the dynamic pages. After you launch an
instance with this AMI, your application is running and ready to
accept requests.
https://s3.amazonaws.com/cloudformation-examples/BoostrappingApplicationsWithAWSCloudFormation.pdf
Should you plan to use Cloudformation:Init inside your template to add additional configuration when your instance will start, be sure to install cfn tools as well (cfn-init, cfn-hup, cfn-signal...)
More details about Cloudformation:Init : http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html
How to install cfn helper scripts : http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-helper-scripts-reference.html
Yes.
When you are specifying the instance in the cloud formation script you can use "ImageID": "" <- put in the AMI ID
ImageId
Provides the unique ID of the Amazon Machine Image (AMI) that was assigned during registration.
Required: Yes
Type: String
Update requires: Replacement
I've been following the official Amazon documentation on deplaying to the Elastic Bean Stalk.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python.html
and the customization environment
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html#customize-containers-format
however, I am stuck. I do not want to use the built in RDS database I want to use mongodb but have my django/python application scale as a RESTful frontend or rather API endpoint for my users.
Currently I am running one EC2 instance to test out my django application.
Some problems that I have with the Elastic Bean:
1. I cannot figure out how to run commands such as
pip install git+https://github.com/django-nonrel/django#nonrel-1.5
Since I cannot install the device mongo driver for use by django I cannot run my mongodb commands.
I was wondering if I am just skipping over some concepts or just not understanding how deploying on the beanstalk works. I can see that beanstalk just launches EC2 instances and possibly need to write custom scripts or something I don't know.
I've searched around but I don't exactly know what to ask in regards to this. Top results of google are always Amazon documents which are less than helpful in customization outside of their RDS environment. I know that Django traditionally uses RDS environments but again I don't want to use those as they are not flexible enough for the web application I am writing.
You can create a customize AMI to your specific needs the steps are outline in the AWS documentation below. Basically you would create a custom AMI with the packages needed to host your application and then update the Beanstalk config to use your customize AMI.
Using Custom AMIs