If you are deploying your Elastic Beanstalk application using a legacy container type, then you need to create a custom Amazon Machine Image (AMI) that Elastic Beanstalk uses for your applications. You can also use custom AMIs to improve the speed of deployments for which scaling activities specified in a configuration file result in a long installation process. To do this, customize the existing Elastic Beanstalk AMI. When you modify an Elastic Beanstalk AMI, do not replace components included in the solution stack. This section describes how to create and deploy a customized Amazon Machine Image (AMI) for use with Elastic Beanstalk.
To create and use a customized AMI
Open the Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
From the region list, select a region.
Launch your Elastic Beanstalk application. For more information on how to launch an Elastic Beanstalk application, go to the Getting Started Using Elastic Beanstalk.
Find the AMI ID used by Elastic Beanstalk to launch your application: Click the environment name, and then click Configuration in the navigation pane. Next to Instances, click . Copy the value in the Custom AMI ID box.
Use the Amazon EC2 console to launch an instance using that AMI ID:
You must use the Amazon EC2 console to launch an instance with the AMI ID. You cannot customize an instance that was launched by Elastic Beanstalk.
Open the Amazon EC2 console.
Click Launch Instance.
On the Choose an Amazon Machine Image (AMI) page, do one of the following:
Click the My AMIs tab to view private AMIs that you own or private AMIs that have been shared with you. Then, in the navigation pane, under Ownership, select the Owned by me check box and the Shared with me check box.
Click the Community AMIs tab to view AMIs provided by the AWS user community.
In the Search my AMIs or Search community AMIs text box, paste the AMI ID that Elastic Beanstalk used to launch your application and press Enter.
In the results list, click the Select button next to the AMI that you want to use to create your customized AMI.
On the Choose an Instance Type page, select the hardware configuration and size of the instance to launch. Larger instance types have more CPU and memory. For more information about instance families, see Instance Types in the Amazon Elastic Compute Cloud User Guide.
To stay within the free tier, select the t1.micro instance, and then click Next: Configure Instance Details.
On the Configure Instance Details page, click Advanced Details to expand the list of configuration options.
In the User data text box, type the following:
<repository version number>repo_upgrade: none
Specify the value of repo_releasever
according to the repository version number of the AMI for your
container. For example, the repository version number of the AMI
for the container with the name 32bit Amazon Linux
2014.02 running Node.js is
2013.09. For more information about
the AMI version number for your container name, see the
AMI column in Supported Platforms.
These settings configure the lock-on-launch feature, which causes the AMI to use a fixed, specific repository version when it launches, and disables the automatic installation of security updates. Both are required to use a custom AMI with Elastic Beanstalk.
Continue using the Amazon EC2 wizard to launch the Elastic Beanstalk AMI that you want to customize.
When launching the instance using the AWS Management Console, make sure that you create or specify a key pair and that you select your Amazon EC2 security group for your Elastic Beanstalk environment.
For additional information on how to launch an Amazon EC2 instance, go to Running an Instance in the Amazon Elastic Compute Cloud User Guide.
Connect to the instance. For more information on connecting to an Amazon EC2 instance, go to Connecting to Instances in the Amazon Elastic Compute Cloud User Guide.
After customizing a windows instance, you need to run the EC2Config service Sysprep. For information about EC2Config, go to Configuring a Windows Instance Using the EC2Config Service.
If you are using an AMI with Apache and Tomcat, you will need to perform your customizations.
Apache and Tomcat are not automatically started when you manually launch the Elastic Beanstalk AMI using the Amazon EC2 tab on the AWS Management Console. Enter the following commands at your Amazon EC2 instance's command prompt to start Apache and Tomcat.
sudo -s cd /etc/init.d ./httpd start ./tomcat7 start
From the Amazon EC2 console on the AWS Management Console, select the running instance that you've just modified and select Create Image (EBS AMI) from the Instance Actions menu. For more information on how to create an image from a running instance, go to Creating an Image from a Running Instance in the Amazon Elastic Compute Cloud User Guide. You can also view the Create Your Own Customized AMI video.
To avoid incurring additional AWS charges, terminate the Amazon EC2 instance you used to create the AMI. For instructions on how to terminate an instance, go to Terminate Your Instance in the Amazon Elastic Compute Cloud User Guide.
To use your custom AMI, specify your custom AMI ID in the Custom AMI ID text box in the Elastic Beanstalk Edit Configuration dialog box. Existing instances will be replaced with new instances launched from the new custom AMI.