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.
Related
I want to confirm my approach to setting up a VPC using cloudformation/scepter and seeding instances with docker container is correct.
Create an aws ec2 instance.
Create a docker image on that instance
Create a cloudformation VPC template (.yaml )
-reference docker image in template?
Create a sceptre project using the template above and run script from ec2 instance
So as I understand if the majority of the work will be in the cloudformation template. Currently I'm stuck on sceptre errors, but I wanted to make sure I was approaching the problem correctly. Does this look like the right approach?
There are a lot of ways of doing what you want:
Run sceptre locally on your development machine
This is easier, but not best practice for important environments as
having a build server, gives a better trail of what was done when (especially in shared environments)
Use CodeBuild to save you having to do steps 1 & 2 yourself (AWS maintain a docker image with python installed)
It also avoids the chicken and egg problem of how you deploy the EC2 instance in the first place.
Configure Jobs on a build server such as Jenkins
CodeDeploy is good for simple setups, but a well configured build server, can have dashboards to track what is deployed where
as sceptre is just a way of generating/managing deploying templates across environments, there are lots of other ways of doing this including what you outlined.
p.s Apologies that the getting started documentation isn't great at the moment, it is something we are focusing on for release 2.0.
I have an amazon ec2 instance with RHEL 7.3 on it. I would like to convert this into an iso so that I can migrate it wherever I want. What are the best tools to create an iso of a virtual machine. Or how do I clone/backup this VM so that I can restore it anywhere I want?
You can work with VM and AWS programatically via AWS CLI commands.
You want to get familiar with import-task and export-task commands.
The best place to start is by reading an official AWS guides for:
Exporting an Instance as a VM Using VM Import/Export
Importing a VM as an Image Using VM Import/Export
The key information you need to pick up from the guide is this quote:
"You can't export an instance from Amazon EC2 unless you previously
imported it into Amazon EC2 from another virtualization environment."
Yes, there are solutions, one of them linked by #Nicholas Smith. That being said, if you go the unofficial route you might end up in a dark alley where help might not be available. I highly recommend and warn here to not proceed with trying to clone EC2 into VM at this point. You will spend a lot of time with a huge risk factor for future.
For you to be able to achieve what you want, you need to create a RHEL VM using any VM software, you need to load this VM into AWS and then you will be able to work with VM in AWS making any necessary changes and export again for local or transportation needs.
As you are running a widely-used Linux distribution - RHEL, you can attempt to recreate your EC2 environment manually by launching a VM that runs the same kernel version along with the same package versions. From there, you can tarball what files you need from your production instance and copy them over to your on-premise site by using SCP/SFTP.
Just get your RHEL environment into VM locally and import to AWS and you set.
Clonezilla provides functionality to create images. Generated images can be converted to ISO files.
It doesn't seem to be something that Amazon promote as a service however the aws cli tools have an ec2-unbundle command for extracting from an AMI. There's a guide here on how to download and run an EC2 AMI locally by using it.
Caveat is it appears the ec2-unbundle command currently only works on Linux and not OS X or Windows.
We are attempting to setup mod_pagespeed on AWS (through SSH), but came across the below message indicating that changes will be lost if a new instance is created.
This EC2 instance is managed by AWS Elastic Beanstalk. Changes made via SSH WILL BE LOST if the instance is replaced by auto-scaling.
I've attempted searching online for a solution to this, but am not yet fully familiar with AWS terminology - and therefore am a little lost. Anyone have any ideas / recommendations on how to proceed? If there's a viable option other than SSH, I'm all ears. Thanks in advance! :)
Take a look at the ElasticBeanstalk doc on Customizing Software on Linux Servers, especially the Packages section. By specifying the extra packages in EB's own config file format, these packages will be installed with each new instance, and when the environment is created. ElasticBeanstalk provides essentially the same options as EC2 Metadata for packages, files, etc., using config files in your application version bundle.
The downside is that there is a learning curve to these config files, and getting your service configured properly is a bit different than just doing it yourself via SSH. But it is more repeatable and in line with how ElasticBeanstalk is designed to work.
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
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.