Amazon Elastic Beanstalk

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/Welcome.html
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.html

What iss AWS Elastic Beanstalk and Why do I need it?

It is an automated way to deploy and manage applications in the AWS cloud. You simply upload your application, and Elastic Beanstalk automatically handles the deployment details of capacity provisioning, load balancing, auto-scaling, and application health monitoring.

There are many ways to get your applications up and running using AWS. If you have a Java, .NET, Node.js, PHP, Python, or Ruby application and you want to deploy and manage your application quickly without manually creating the necessary AWS infrastructure, you can use AWS Elastic Beanstalk. You upload your application, and AWS Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring. AWS Elastic Beanstalk reduces management complexity without restricting choice or control.

Amazon Web Services (AWS) comprises about 25 services, each of which exposes an area of functionality. While the variety of services offers flexibility for how you want to manage your AWS infrastructure, it can be challenging to figure out which services to use and how to provision them. With AWS Elastic Beanstalk, you can quickly deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs those applications. AWS Elastic Beanstalk reduces management complexity without restricting choice or control. You simply upload your application, and AWS Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring. AWS Elastic Beanstalk uses highly reliable and scalable services that are available in the AWS Free Usage Tier such as:

  • Amazon Elastic Compute Cloud (Amazon EC2)
  • Amazon Simple Storage Service (Amazon S3)
  • Amazon Simple Notification Service (Amazon SNS)
  • Amazon CloudWatch
  • Elastic Load Balancing
  • Auto Scaling

You can also perform most deployment tasks, such as changing the size of your fleet of Amazon EC2 instances or monitoring your application, directly from the AWS Elastic Beanstalk web interface. To use AWS Elastic Beanstalk, you create an application, upload an application version (for example, a Java .war file) to AWS Elastic Beanstalk, and then provide some information about the application. Elastic Beanstalk automatically launches an environment and creates and configures the AWS resources needed to run your code. After your environment is launched, you can then manage your environment and deploy new application versions.

After you create and deploy your application, information about the application—including metrics, events, and environment status—is available through the AWS Management Console, APIs, and CLI.

AWS Elastic Beanstalk provides developers and systems administrators an easy, fast way to deploy and manage your application without having to worry about AWS infrastructure.

If you already know the AWS resources you want to use and how they work, you might prefer AWS CloudFormation to create your AWS resources by creating a template. You can then use this template to launch new AWS resources in the exact same way without having to recustomize your AWS resources. Once your resources are deployed, you can modify and update the AWS resources in a controlled and predictable way, providing the same sort of version control over your AWS infrastructure that you exercise over your software. For more information about AWS CloudFormation, go to AWS CloudFormation Getting Started Guide.

AWS Elastic Beanstalk provisions

  • EC2 instances
  • Elastic Load Balancer
  • Auto Scaling configuration
  • Health monitoring and notification

Is there a charge for using AWS Elastic Beanstalk?

No. AWS Elastic Beanstalk is just a way to deploy your application onto AWS infrastructure. You only pay for the underlying resources that you use.

Quick facts about elastic beanstalk:

  1. On beanstalk instances by default installed java open sdk.
  2. In the folder: /opt/elasticbeanstalk/hooks you can find scripts which do deploy
  3. By default beanstalk deploy application to the /var/lib/tomcat6/

What are the key features or benefits of using Elastic Beanstalk?

  1. If you have a application (Java, .NET, Node.js, PHP, Python, or Ruby) and you want to deploy and manage your application quickly without manually creating the necessary AWS infrastructure, you can use AWS Elastic Beanstalk. Beanstalk automatically provision EC2, S3, CloudWatch, Elastic Load Balancing, and Auto Scaling.
  2. You can also perform most deployment tasks, such as changing the size of your fleet of Amazon EC2 instances or monitoring your application, directly from the AWS Elastic Beanstalk web interface.

Does AWS Elastic Beanstalk support programming language other than Java?

Yes. See http://aws.amazon.com/elasticbeanstalk/. For Node.js, PHP, Python, and Ruby developers, to deploy your application using AWS Elastic Beanstalk, you simply:

  1. Create your application as you normally would using any editor or IDE.
  2. Create an Elastic Beanstalk Node.js, PHP, Python, or Ruby environment using the AWS Management Console, the command line interface, or the web service APIs. Behind the scenes, Elastic Beanstalk handles the provisioning of a load balancer and Amazon EC2 resources.
  3. Install and configure Git for deployments.
  4. Commit and push your changes using Git. Elastic Beanstalk deploys your files to one or more Amazon EC2 instances running the Apache HTTP Server.
  5. Within a few minutes you will be able to access your application at a customized URL (e.g. http://myapp.elasticbeanstalk.com/).

What are the basic steps?

  1. Sign up for the Service:
  2. Create an Application
  3. View Information About Your Environment
  4. Deploy New Version
  5. Change Configuration

How can we sign up for Beanstalk?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. Follow the on-screen instructions. If you have never registered for Amazon EC2, part of the sign-up procedure for AWS Elastic Beanstalk will include receiving an automated telephone call and entering a PIN using the telephone keypad.

How can we create an application?

In this example, we will create and deploy a sample application that is already prepared. Perhaps, after this is done, we can customize this application.

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. Select a platform and then click Get Started.

How can we view information about your environment?

After you create the AWS Elastic Beanstalk application, you can view information about the application you deployed and its provisioned resources by going to the environment dashboard in the AWS Management Console. The dashboard shows the health of your application's environment, the running version, and the environment configuration.

While AWS Elastic Beanstalk creates your AWS resources and launches your application, the environment will be in a Launching (gray) state. Status messages about launch events are displayed in the environment's dashboard.

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the AWS Elastic Beanstalk applications page, click DEFAULT-ENVIRONMENT in the My First Elastic Beanstalk Application application. From the dashboard you can view the status of the environment, the running application version, the platform, and a list of recent events. If the environment health is gray, the environment is still in the process of being launched.
  3. You can also view additional details about the environment by going to other pages from the dashboard:
    • The Configuration page shows the resources provisioned for this environment, such as Amazon EC2 instances that host your application. This page also lets you configure some of the provisioned resources.
    • The Logs page shows snapshots of all your servers.
    • The Monitoring page shows the statistics for the environment, such as average latency and CPU utilization. This page also lets you create alarms for the metrics that you are monitoring.
    • The Alarms page shows the CloudWatch alarms you've created for this environment.
    • The Events page shows any informational or error messages from services that this environment is using.

How can we deploy a new version of your application?

You can update your deployed application, even while it is part of a running environment. For a Java application, you can also use the AWS Toolkit for Eclipse to update your deployed application; for instructions, see Edit the Application and Redeploy. For a PHP application, it is easy to update your application using a Git deployment via eb; for instructions, see Deploying AWS Elastic Beanstalk Applications in PHP. For a .NET application, you can use the AWS Toolkit for Visual Studio to update your deployed application; for instructions, see Edit the Application and Redeploy.

The application version you are running now is labeled Sample Application.

  1. Download one of the following sample applications that match the configuration for your environment. For Java, go to https://elasticbeanstalk-us-east-1.s3.amazonaws.com/resources/elasticbeanstalk-sampleapp2.war and save the file as sample.war. For other language, refer to http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.Walkthrough.html
  2. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  3. From the AWS Elastic Beanstalk applications page, click My First Elastic Beanstalk Application and then click Default-Environment.
  4. In the Overview section, click Upload and Deploy and then enter details about the application version.
  5. Click Deploy. Your new application version is uploaded and added to the table of application versions.
  6. To view the table of application versions, click My First Elastic Beanstalk Application and then click Application Versions.
  7. From the table of application versions, select Sample Application Second Version and then click Deploy.
  8. Verify that you have the correct environment selected (Default-Environment) and then click Deploy. AWS Elastic Beanstalk now deploys your file to your Amazon EC2 instances. You can view the status of your deployment on the environment's dashboard. The Environment Health status turns gray while the application version is updated. When the deployment is complete, AWS Elastic Beanstalk performs an application health check. The status returns to green when the application responds to the health check.

What customization can we perform when we use Elastic Beanstalk?

  • Type of EC2 instances. For example, if you have a compute-intensive application, you can change the type of Amazon EC2 instance that is running your application.

How long does it take to make a customization effective?

Some configuration changes are simple and happen quickly. Some changes require AWS Elastic Beanstalk to delete and recreate AWS resources, which can take several minutes. AWS Elastic Beanstalk will warn you about possible application downtime when changing configuration settings.

How can we change your configuration?

  1. To change your environment configuration:
    1. Go back to the environment dashboard by clicking My First Elastic Beanstalk Application and then Default-Environment.
    2. In the Overview section, click Edit.
    3. In the Scaling settings, click on the gear icon
    4. In the Auto Scaling section, change Minimum Instance Count from 1 to 2. This increases the minimum number of Auto Scaling instances deployed in Amazon EC2.
    5. At the bottom of the page, click Save. The environment update may take a few minutes. When the environment is ready, you can go to the next task to verify your changes.
  2. To verify changes to load balancers:
    1. In the left navigation, click Events. You will see the event Successfully deployed new configuration to environment in the events list. This confirms that the Auto Scaling minimum instance count has been set to 2. A second instance is launched automatically.
    2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
    3. In the navigation pane, under NETWORK & SECURITY, click Load Balancers.
    4. Click Load Balancer Name awseb-<your environment name> in the list of load balancers.
    5. Click Instances tab in the Load Balancer: awseb-<your environment name> pane. The information shows that two instances are associated with this load balancer, corresponding to the increase in Auto Scaling instances.

How can we create and deploy a sample application using Elastic Beanstalk?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/
  2. Select a platform, and then click Get Started. This process may take several minutes to complete. To begin creating the necessary components to run the sample application on AWS resources, AWS Elastic Beanstalk does the following:
    1. Creates a placeholder AWS Elastic Beanstalk application named "My First Elastic Beanstalk Application."
    2. Creates a new application version labeled "Sample Application" that refers to a default sample application file.
    3. Launches an environment named "Default-Environment" that provisions the AWS resources to host the application.
    4. Deploys the "Sample Application" application into the newly created "Default-Environment."

How can we see the published version of your application?

  1. In the AWS Elastic Beanstalk console, click the environment that is hosting your application. In this walkthrough, "Default-Environment."
  2. Click the link that appears right after the environment name, in this example: Default-Environment-y6vfppmxai.elasticbeanstalk.com
  3. The application page opens in a new tab.

How can we change your environment configuration?

You can customize your environment to receive email notifications about important events for your application. Some configuration changes are simple and happen quickly. Others require that AWS Elastic Beanstalk delete and re-create AWS resources, which can take several minutes. AWS Elastic Beanstalk will warn you about possible application downtime before it changes configuration settings. For this example, you will add your email address to receive event notifications.

  1. In the AWS Elastic Beanstalk console, click the environment that is hosting your application.
  2. Click Configuration
  3. Click the settings gear in the Notifications box.
  4. In the Email box, type your email address, and then click Save.

How can we delete an Application and Environment?

To completely delete the application, terminate the environment, delete all application versions, delete the application. This procedure is destructive. Make sure you know exactly what you want to do. Back up your database content, your file system content, your code, and your configurations.

  1. Terminate the environment:
    1. In the AWS Elastic Beanstalk console, click the environment that is hosting your application.
    2. Click Actions and then click Terminate Environment.
    3. In the Terminate Environment dialog box, click Terminate. This process may take several minutes to complete.
  2. Delete all application versions:
    1. In the AWS Elastic Beanstalk console, click Actions and then View Application Versions.
    2. Select the check box next to your application versions and click Delete.
    3. In the Delete Application Version dialog box, select the Delete versions from Amazon S3 check box.
    4. Click Delete.
  3. To delete the application
    1. In the AWS Elastic Beanstalk console, click Actions and then Delete Application.
    2. In the Delete Application dialog box, click Delete.

How can we completely delete the application?

  1. Delete all application versions:
    1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
    2. From the AWS Elastic Beanstalk applications page, click DEFAULT-ENVIRONMENT in the My First Elastic Beanstalk Application application.
    3. Click Upload and Deploy
    4. When prompted for an application, click All Versions.
    5. Select all application versions that you want to delete, and then click Delete.
    6. Confirm the versions that you are deleting, and then click Delete.
    7. Click Done.
  2. Terminate the environment.
    1. Go back to the environment dashboard by clicking My First Elastic Beanstalk Application and then Default-Environment.
    2. Click Actions and then click Terminate Environment.
    3. Confirm that you are terminating Default-Environment and then click Terminate.
  3. Delete the My First Elastic Beanstalk Application AWS Elastic Beanstalk application.
    1. Click Elastic Beanstalk at the upper left to return to the main dashboard.
    2. From the AWS Elastic Beanstalk applications page, click Actions for the My First Elastic Beanstalk Application application and then click Delete Application.
    3. Confirm that you want to delete this AWS Elastic Beanstalk application by clicking Delete.

What can we do with the Beanstalk Management Console?

The AWS Beanstalk Management Console enables you to manage applications through AWS Elastic Beanstalk from a single web browser interface. The console provides access to all of your deployed applications and gives you the ability to manage and monitor your applications and environments. From the console you can:

  • Create and delete applications
  • Add and delete application versions
  • Create and delete environments
  • Identify the running version within an environment
  • View operational metrics
  • View application and environment logs

The AWS Management Console is available at http://console.aws.amazon.com/elasticbeanstalk.

When we provision a new Elastic Beanstalk environment, what are the components that get created?

AWS resources created for an environment include one elastic load balancer (ELB in the diagram), an Auto Scaling group, and one or more Amazon EC2 instances. Auto Scaling automatically starts additional Amazon EC2 instances to accommodate increasing load on your application. If the load on your application decreases, Auto Scaling stops instances, but always leaves at least one instance running.

In an Elastic Beanstalk environment, each EC2 instance has a component known as the Host Manager. What is the role of this Host Manager component?

  1. Deploying the application
  2. Aggregating events and metrics for retrieval via the console, the API, or the command line
  3. Generating instance-level events
  4. Monitoring the application log files for critical errors
  5. Monitoring the application server
  6. Patching instance components
  7. Rotating your application's log files and publishing them to Amazon S3

Is the data between Elastic Load Balancer and EC2 instances encrypted?

No. Data moving between the Elastic Load Balancer and the Amazon EC2 instances is unencrypted. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.concepts.design.html

Do your Elastic Beanstalk servers receive automated updates and patches?

No.

What do you have to do so that your servers receive automated updates and patches?

AWS Elastic Beanstalk does not currently have a software update mechanism or policy. AWS Elastic Beanstalk periodically updates its default AMIs with new software and patches. Running environments, however, do not get automatically updated. To obtain the latest AMIs, you must launch a new environment. For more information about launching a new environment, see [ http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.environments.html Launching New Environments].

To connect to Tomcat RDS environments you must load the driver explicitly using Class.forName(<driverClassName>) prior to the call to DriverManager.getConnection() in the Java code.

After developing and testing your application locally, you will typically deploy your application to AWS Elastic Beanstalk. After deployment, your application will be live at a URL such as http://myexampleapp-wpams3yrvj.elasticbeanstalk.com. Because your application is live, you should consider setting up multiple environments, such as a testing environment and a production environment. You can use the AWS Toolkit for Eclipse if you want to set up different AWS accounts for testing, staging, and production. For information about managing multiple accounts, see Managing Multiple AWS Accounts.

After you remotely test and debug your AWS Elastic Beanstalk application, you can make any updates and then redeploy to AWS Elastic Beanstalk. After you are satisfied with all of your changes, you can upload the latest version to your production environment.

What is the definition of environment property?

Environment properties are specific to your application environment and are not actual (shell) environment variables. More specifically, PARAM1, PARAM2, etc. are system properties passed into the JVM at startup using the -D flag. You can use them to pass database connection strings, security credentials, or other information that you don't want to hard-code into your application. Storing this information in environment properties can help increase the portability and scalability of your application. You do not need to recompile your source code when you move between environments. You can acquire them with System.getProperty(name).

How can we create an application?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select a region in which to create the AWS Elastic Beanstalk application.
  3. On the AWS Elastic Beanstalk application navigation bar, click Create New Application.
  4. Enter the name of the application and, optionally, a description. Then click Create.
  5. To launch a new environment in which your application will be deployed, continue with the wizard by selecting the platform and environment type. Note the following:
    • The Predefined configuration is the platform and version that will be used for the environment. For more information, see Supported Platforms. After you launch an environment with a specific configuration, you cannot change the configuration. If your application requires a different configuration, you must launch a new environment.
    • The Environment type specifies whether the environment is load balancing and autoscaling or just a single instance. For more information, see Environment Types. If you want to launch a new environment and deploy an application later, clear the selection for the Launch a new environment running this application setting. Then click Done. You are directed to the AWS Elastic Beanstalk applications page.
  6. Specify the source for your application version. You can use a sample application or upload your own. To upload your own, click Choose File, select your application, and then click Continue. AWS Elastic Beanstalk supports only a single .war file for a Java application version and only a single .zip file for other applications. The file size limit is 512 MB.
  7. Enter the details of your environment.
    1. Enter a name for the environment.
    2. Enter a unique environment URL. Even though the environment URL has a default name, you can enter a different name for the URL. AWS Elastic Beanstalk uses this name to create a unique CNAME for the environment. You can check the availability of the URL by clicking Check Availability.
    3. Optional: Enter a description for this environment.
    4. Click Continue.
  8. Optional: Select additional resources for the environment, and then click Continue.
  9. Set configuration details for the environment as explained below. Then click Continue.
    • Instance type displays the instance types available to your AWS Elastic Beanstalk environment. Select a server with the characteristics (including memory size and CPU power) that are most appropriate to your application.
    • EC2 key pair shows all the Amazon EC2 key pairs in your AWS account. Select a key pair if you need to securely log in to the Amazon EC2 instances provisioned for your AWS Elastic Beanstalk application. See Using Credentials
    • Email Address specifies who receives Amazon Simple Notification Service (Amazon SNS) notifications about important events regarding your application. If you want to receive email notifications of important events, enter an email address. You can disable Amazon SNS notifications at a later time by removing the email address in the configuration settings of your running environment.
    • For load-balancing, autoscaling environments, Application health check URL specifies a resource in your application that Elastic Load Balancing checks for a 200 OK response. For more information, see Monitoring Application Health.
    • Enable rolling updates provides options for managing how instances are updated or replaced. For more information, see Updating AWS Elastic Beanstalk Environments with Rolling Updates. You can configure rolling updates after you have saved your environment configuration. Rolling updates uses default settings when first enabled.
    • If you are using a nonlegacy container, you can select an instance profile. If you are using a legacy configuration, this option does not appear. An instance profile provides applications and services access to AWS resources using temporary security credentials. For example, if your application requires access to Amazon DynamoDB, it must use AWS security credentials to make an API request. The application can use the temporary security credentials so you do not have to store long-term credentials on an Amazon EC2 instance or update the instance every time the credentials are rotated. In addition, AWS Elastic Beanstalk requires an instance profile to rotate logs to Amazon S3. The Instance Profile list displays the profiles available for your AWS Elastic Beanstalk environment. If you do not have an instance profile, you can select Create a default instance profile. AWS Elastic Beanstalk creates a default instance profile and updates the Amazon S3 bucket policy to allow log rotation. If you choose to not use the default instance profile, you need to grant permissions for AWS Elastic Beanstalk to rotate logs. For instructions, see Using a Custom Instance Profile. For more information about log rotation, see AWS Elastic Beanstalk Environment Configurations. For more information about using instance profiles with AWS Elastic Beanstalk, see Using IAM Roles with AWS Elastic Beanstalk. Users must have permission to create a default profile. For more information, see Granting IAM Users Permissions to Create and Pass IAM Roles.
  10. If you are creating an application using a nonlegacy configuration and selected to associate an Amazon RDS DB, set the Amazon RDS configuration settings as explained below. Then click Continue.
    • For Snapshot, select whether to create an Amazon RDS DB from an existing snapshot.
    • For DB Engine, select a database engine.
    • For Instance Class, select a database instance class. For information about the DB instance classes, go to http://aws.amazon.com/rds/.
    • For Allocated Storage, type the space needed for your database. In some cases, allocating a larger amount of storage for your DB instance than the size of your database can improve IO performance. For information about storage allocation, go to Features.
    • For Username, type a name using alphanumeric characters that you will use to log on to your DB instance with all database privileges.
    • For Password, type a password containing from 8 to 16 printable ASCII characters (excluding /, \, and @).
    • To configure your database across multiple availability zones, select Multiple Availability Zones. Running your database instance in multiple Availability Zones safeguards your data in the unlikely event of a database instance component failure or service health disruption in one Availability Zone.
  11. Review your application and environment information, and then click Create. The new environment is launched with your new application. Note that it can take several minutes for the new environment to start while AWS Elastic Beanstalk is provisioning AWS resources.

How can we create a new version of your application?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the application that you want to work with.
  3. From the AWS Elastic Beanstalk console applications page, click Actions for the application that you want to add an application version to.
  4. Select View Application Versions to view a list of application versions.
  5. Click Upload.
    • Enter a label for this version in the Version Label field.
    • Enter a brief description for this version in the Description field.
    • Click Choose file to specify the location of the application version (WAR or ZIP file). AWS Elastic Beanstalk supports only a single WAR file for a Java application version and only a single ZIP file for other applications. The file size limit is 512 MB.
    • Click Upload

How can we launch a new environment?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that has the application that you want to work in.
  3. From the AWS Elastic Beanstalk console applications page, click Actions for the application that you want to launch a new environment in.
  4. Select Launch New Environment.
  5. Select a predefined configuration, or if you have any saved configurations, you can select one of them.
    • The Predefined configuration is the platform and version that will be used for the environment. For more information, see Supported Platforms. After you launch an environment with a specific configuration, you cannot change the configuration. If your application requires a different configuration, you must launch a new environment.
    • The Environment type specifies whether the environment is load balancing and autoscaling or just a single instance. For more information, see Environment Types.
  6. For the Application Version, you can specify an existing application version or upload a new application version, and then click Continue.
  7. Enter the details of your environment.
    • Enter a name for the environment.
    • Enter a unique environment URL. Even though the environment URL is populated with the environment name, you can enter a different name for the URL. AWS Elastic Beanstalk uses this name to create a unique CNAME for the environment. You can check the availability of the URL by clicking Check Availability.
    • Optional: Enter a description for this environment.
    • Click Continue
  8. Optional: Select additional resources for the environment, and then click Continue.
  9. Set configuration details for the environment, and then click Continue.

How can we deploy an existing application version to an existing environment?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the environment that want to work in.
  3. From the AWS Elastic Beanstalk console applications page, click the name of the environment that you want to deploy an existing application version to.
  4. Click Deploy in order to view a list of all applications versions that you can deploy for this environment. The listed application versions are associated with this AWS Elastic Beanstalk application.
  5. Select the application version that you want to deploy, and then click Deploy.
  6. Verify that you are deploying the right application version in the right environment, and then click Deploy.

AWS Elastic Beanstalk now deploys your file to your Amazon EC2 instances. You will see the environment start the update process. If you specified a health check URL, there's an application health check when the deployment is complete. The environment returns to green when the application responds to the health check. For more information, see Monitoring Application Health. If you need to deploy an application version with zero downtime, see Deploying Versions with Zero Downtime. If you view the environment dashboard, you can verify the application version.

How can we do deployment with zero downtime?

It is possible to avoid this downtime by swapping the CNAMEs for your environments. To do the swap, you need to upload the updated application version and then create a new environment running that version.

If you have created an Alias record to map your root domain to your Elastic Load Balancer using Route 53, then after you have created you new environment, you will need to change your resource record set to map your root domain to the Elastic Load Balancer in your new environment.

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that has the application that you want to work with.
  3. From the AWS Elastic Beanstalk console applications page, click Actions for the application that you want to add an application version to.
  4. Select View Application Versions to view a list of application versions.
  5. Click Upload.
    • Enter a label for this version in the Version Label field.
    • Enter a brief description for this version in the Description field.
    • Click Choose File to specify the location of the application version (WAR or ZIP file). AWS Elastic Beanstalk supports only a single WAR file for a Java application version and only a single ZIP file for other applications. The file size limit is 512 MB.
    • Click Upload
  6. Save the configuration for the live environment by clicking Actions and then selecting Save Configuration from the environment's dashboard. For more information, see Saving Environment Configuration Settings. You'll use this configuration to create a new environment that will run the updated application version.
  7. Launch a new environment with your new application version and saved configuration. For more information, see Launching New Environments.
  8. Verify that your new environment is ready by viewing its dashboard. If the environment has an error, view the events and logs for the environment in order to troubleshoot any errors.
  9. From the new environment's dashboard, click Actions and then select Swap Environment URL.
  10. From the Environment Name drop-down list, select the current live environment name in order to use that environment's URL for the new environment.
  11. Click Swap URLs.
  12. Delete your old environment after you confirmed the swap operation has completed.

How can we monitor our environment?

  1. To view metrics for an environment:
    1. From the AWS Elastic Beanstalk console applications page, click an environment name to view the environment dashboard.
    2. In the left navigation, click Monitoring. The Monitoring page shows you overall statistics about your environment, such as CPU utilization and average latency. In addition to the overall statistics, you can view monitoring graphs that show resource usage over time. You can click any of the graphs to view more detailed information. By default, only basic CloudWatch metrics are enabled, which return data in five-minute periods. You can enable more granular one-minute CloudWatch metrics by editing your environment's configuration settings.
  2. To add a metric to the Monitoring page:
    1. In the Monitoring section of the Monitoring page, click Edit.
    2. In the Add Graph section, select the resource, metric, statistic, and dimension that you want to add. For more information about metrics and dimensions for each resource, see Amazon CloudWatch Metrics, Namespaces, and Dimensions Reference
    3. After you select the details of the graph, click Add.
    4. If you want to add another graph, select details for the new graph and then click Add Another.
    5. After you completed adding the graphs that you want, click Save. The graphs are added to the Monitoring page.

How can we check the state of your alarms?

  1. From the AWS Elastic Beanstalk console applications page, click the environment name that you want to manage alarms for.
  2. From the navigation menu, click Alarms to see a list of alarms. If any alarms is in the alarm state, they are flagged with (warning).
  3. To filter alarms, click the drop-down filter and select the filter that you want.
  4. To edit or delete an alarm, click (edit) or (delete).

How can we create an alarm?

  1. From the AWS Elastic Beanstalk console applications page, click the environment name that you want to add alarms to.
  2. From the navigation menu, click Monitoring.
  3. For the metric that you want to create an alarm for, click on the bell . You are directed to the Alarms page.
  4. Enter details about the alarm:
    • Name: A name for this alarm.
    • Description (optional): A short description of what this alarm is.
    • Period: The time interval between readings.
    • Threshold: Describes the behavior and value that the metric must exceed in order to trigger an alarm.
    • Change state after: The amount a time after a threshold has been exceed that triggers a change in state of the alarm.
    • Notify: The Amazon SNS topic that is notified when an alarm changes state.
    • Notify when state changes to:
      • OK: The metric is within the defined threshold.
      • Alarm: The metric exceeded the defined threshold.
      • Insufficient data: The alarm has just started, the metric is not available, or not enough data is available for the metric to determine the alarm state.
  5. Click Add. The environment status changes to gray while the environment updates. You can view the alarm that you created by going to the Alarms page.

How can we view environment and application events?

  1. From the AWS Elastic Beanstalk console applications page, click an environment name to view the environment dashboard.
  2. From the navigation menu, click Events. The Events page shows you a list of all events that have been recorded for the environment and application version. You can filter on the type of events by using the Severity drop-down list. You can also filter when the events occurred by using the time slider.

What are available environmental types?

  • Load balancing / Auto-Scaling
  • Single instance: A single-instance environment contains one Amazon EC2 instance with an Elastic IP address. A single-instance environment doesn't have a load balancer, which can help you reduce costs compared to a load-balancing, autoscaling environment. Use a single-instance environment if you expect your production application to have low traffic or if you are doing remote development. Because a single-instance environment is not load balancing or autoscaling, you can't configure those settings. If you try, error messages explain that those setting are not applicable. Also, any IAM users that work with single-instance environments don't need Elastic Load Balancing permissions. However, users still need Auto Scaling permissions.

In AWS Elastic Beanstalk, you can create a load-balancing, autoscaling environment or a single-instance environment. The type of environment that you require depends on the application that you deploy. For example, you can develop and test an application in a single-instance environment to save costs and then upgrade that environment to a load-balancing, autoscaling environment when the application is ready for production.

Can we change environmental type?

Yes. See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.changetype.html

How can we change environmental type?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the environment that you want to work with.
  3. On the AWS Elastic Beanstalk console applications page, click the name of the environment.
  4. In the Overview section of the environment dashboard, click Edit.
  5. Click Edit (the tool icon) for the Scaling settings.
  6. In the Environment Type section, select the type of environment that you want. The single-instance environment type is available for nonlegacy containers only.
  7. If your environment is in a VPC, you need to specify additional settings.
  8. Click Save. It can take several minutes for the environment to update while AWS Elastic Beanstalk provisions AWS resources.

How can we save an application's environment settings?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the environment that you want to work with.
  3. On the AWS Elastic Beanstalk console applications page, click the name of the environment whose settings you want to save.
  4. On the environment dashboard, click Actions and then select Save Configuration.
  5. For Configuration Name, type the name of the configuration.
  6. Optional: For Description, type a description for this configuration.
  7. Click Save.

How can we edit an application's environment settings?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the environment that you want to work with.
  3. On the AWS Elastic Beanstalk console applications page, click the name of the environment whose settings you want to edit.
  4. In the Overview section of the environment dashboard, click Edit.
  5. For any of the configuration settings, click Edit (the tool icon) in order to edit its configuration.

Can we customize the EC2 instance types?

Yes. You can edit the AWS Elastic Beanstalk environment's Amazon EC2 instance configuration by editing Instances on the Configuration page for that environment. For information about getting to the Configuration page, see Changing Environment Configurations Settings.

How can we setup EC2 Security Group and configure Beanstalk to use that security group?

You can control access to your AWS Elastic Beanstalk application using an Amazon EC2 security group. A security group defines firewall rules for your instances. These rules specify which ingress (i.e., incoming) network traffic should be delivered to your instance. All other ingress traffic will be discarded. You can modify rules for a group at any time. The new rules are automatically enforced for all running instances and instances launched in the future.

You can set up your Amazon EC2 security groups using the Amazon EC2 console. You can specify which Amazon EC2 security groups control access to your AWS Elastic Beanstalk application by entering one or more Amazon EC2 security group names (delimited by commas) into the EC2 security groups text box. For more information on Amazon EC2 security groups, see Using Security Groups in the Amazon Elastic Compute Cloud User Guide.

AWS Elastic Beanstalk creates a default security group for you. If you are using a legacy container, the security group is elasticbeanstalk-default. If you are using a non-legacy container, then AWS Elastic Beanstalk dynamically creates a security group. You can view the security group name in the EC2 security group box.

How can we modify your Amazon EC2 security group?

  1. Add a new rule for 80 (HTTP) for your EC2 security group with a new source. For instructions, see Adding a Security Group Rule in the Amazon Elastic Compute Cloud User Guide.
  2. Type the public DNS address of your EC2 instance in address bar your web browser to verify you can see your application. For instructions on determining your DNS address, see Determining Your IP Addresses in the Amazon Elastic Compute Cloud User Guide.

Can you connect to an EC2 instance that was provisioned by Beanstalk?

Yes.

You can securely log in to the Amazon EC2 instances provisioned for your AWS Elastic Beanstalk application with an Amazon EC2 key pair. You must create an Amazon EC2 key pair and configure your AWS Elastic Beanstalk–provisioned Amazon EC2 instances to use the Amazon EC2 key pair before you can access your AWS Elastic Beanstalk–provisioned Amazon EC2 instances. You can set up your Amazon EC2 key pairs using the AWS Management Console. For instructions on creating a key pair for Amazon EC2, see the Amazon Elastic Compute Cloud Getting Started Guide.

The EC2 key pair text box lets you specify the name of an Amazon EC2 key pair you use to securely log in to the Amazon EC2 instances running your AWS Elastic Beanstalk application.

For more information on Amazon EC2 key pairs, see Using Credentials in the Amazon Elastic Compute Cloud User Guide. For more information on connecting to Amazon EC2 instances, see Connecting to Instances and Connecting to an Instance from Windows using PuTTY in the Amazon Elastic Compute Cloud User Guide.

Can we use a Custom AMI ID with Beanstalk?

You can override the default AMI used for your Amazon EC2 instances with your own custom AMI by entering the identifier of your custom AMI into the Custom AMI ID box in the Server section of the Configuration tab for your environment in the AWS Toolkit for Eclipse. Using your own AMI is an advanced task and should be done with care. If you need a custom AMI, we recommend you start with the default AWS Elastic Beanstalk AMI and then modify it. To be considered healthy, AWS Elastic Beanstalk expects Amazon EC2 instances to meet a set of requirements, including having a running host manager. If these requirements are not met, your environment might not work properly.

What is an instance profile?

Instance profiles provide applications and services access to AWS resources. For example, your application may require access to Amazon DynamoDB. Every API request made to AWS services must be signed using AWS security credentials. One way to grant applications access to AWS resources is to distribute your credentials to each instance; however, distributing long-term credentials to each instance is challenging to manage and a potential security risk. Instead, you can create an IAM role with the permissions that applications require when the application makes calls to other AWS resources. When AWS Elastic Beanstalk launches the Amazon EC2 instances, it uses the instance profile associated with that role. All applications that run on the instances can use the role credentials to sign requests. Because role credentials are temporary and rotated automatically, you don't have to worry about long-term security risks.

In addition, AWS Elastic Beanstalk requires permission to rotate your logs to Amazon S3. If you want AWS Elastic Beanstalk to rotate your logs to Amazon S3, you need to select an instance profile or have AWS Elastic Beanstalk create one for you. For more information about log rotation, see AWS Elastic Beanstalk Environment Configurations.

The Instance profile list displays the profiles available for your AWS Elastic Beanstalk environment. If you do not have any instance profiles, AWS Elastic Beanstalk creates one for you. AWS Elastic Beanstalk creates a default instance profile and updates the Amazon S3 bucket policy to allow log rotation. If you choose to not use the default instance profile, you need to grant permissions for AWS Elastic Beanstalk to rotate logs. For more information about this policy, see Example: Granting AWS Elastic Beanstalk Permission to Rotate Logs to Amazon S3.

Users must have permission to create a default profile. For more information, see Granting IAM Users Permissions to Create and Pass IAM Roles.

Block Device Mappings: You cannot configure this option using the AWS Management Console. Instead, modify the Options.txt file using the command line interface (CLI) as explained in Command Line Interface (CLI). For a list of possible configuration settings, see Option Values. You can also call UpdateEnvironment in the API. For an example of how to configure this option in the API, see API.

Although each Amazon Elastic Compute Cloud instance has an associated root device volume upon launch, you can use block device mappings to specify additional Amazon Elastic Block Store volumes or instance store volumes to attach to all the instances in the autoscaling group. For more information about block device mappings, see Block Device Mapping in the Amazon Elastic Cloud Computer User Guide. For more information about instance storage, see Amazon EC2 Instance Store in the Amazon Elastic Cloud Computer User Guide.

How can we turn on the secure listening port?

Elastic Load Balancing supports the HTTPS/TLS protocol to enable traffic encryption for client connections to the load balancer. Connections from the load balancer to the EC2 instances are done using plaintext. By default, the secure listener port is turned off.

  1. Create and upload a certificate and key to the AWS Access and Identity Management (IAM) service. The IAM service will store the certificate and provide an Amazon Resource Name (ARN) for the SSL certificate you've uploaded. For more information about creating and uploading certificates, see the Managing Server Certificates section of Using AWS Identity and Access Management.
  2. Specify the secure listener port by selecting a port from the Secure Listener Port list.
  3. In the SSL Certificate ID box, enter the Amazon Resources Name (ARN) of your SSL certificate (e.g., arn:aws:iam::123456789012:server-certificate/abc/certs/build). Use the SSL certificate that you created and uploaded in step 1. For information about viewing the certificate's ARN, see Verify the Certificate Object topic in the Creating and Uploading Server Certificates section of the Using IAM guide.

To turn off the secure listener port, select OFF from the Secure Listener Port drop-down list.

If you turn on the secure listener port, you can specify the protocol to use. Select HTTPS or SSL from the Secure Listener Protocol list.

Does Beanstalk support sticky load balancing?

Yes. By default a load balancer routes each request independently to the server instance with the smallest load. By comparison, a sticky session binds a user's session to a specific server instance so that all requests coming from the user during the session will be sent to the same server instance.

AWS Elastic Beanstalk uses load balancer-generated HTTP cookies when sticky sessions are enabled for an application. The load balancer uses a special load balancer–generated cookie to track the application instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If so, the request is sent to the application instance specified in the cookie. If there is no cookie, the load balancer chooses an application instance based on the existing load balancing algorithm. A cookie is inserted into the response for binding subsequent requests from the same user to that application instance. The policy configuration defines a cookie expiry, which establishes the duration of validity for each cookie.

You can use the Sessions section on the Load Balancer configuration page to specify whether or not the load balancer for your application allows session stickiness.

For more information about Elastic Load Balancing, go to the Elastic Load Balancing Developer Guide.

How can we enable rolling update?

Rolling updates provide control over the availability of your environment when you need to update or replace instances in the environment's autoscaling group. You can specify whether to update all instances concurrently or keep some instances running to serve requests even while other instances are being updated. You can also indicate how long the service will wait between consecutive updates.

You can enable and configure rolling updates by editing Rolling Updates on the environment's Configuration page. For information about getting to the Configuration page, see Changing Environment Configurations Settings.

Enabling rolling updates or changing its settings has no effect unless your IAM permissions are configured appropriately. To configure rolling updates, you must configure your IAM policy to allow you to perform any action on any autoscaling group in the AWS account by including a statement with autoscaling:*. For more information about how AWS Elastic Beanstalk uses IAM policies, see Creating Policies to Control Access to Specific AWS Elastic Beanstalk Resources.

The Rolling Updates page has the following options:

  • Max batch size – Specify the number of instances to terminate at any given time. Instances must be terminated before they can be updated or replaced during the rolling update process. By default, this value is one-third of the minimum size of the autoscaling group, rounded to the next highest integer. You can override this with a value between 1 and 10000.
  • Minimum instances in service – Indicate the minimum number of instances to keep running while other instances are being updated. The default value is either the minimum size of the autoscaling group or one less than the maximum size of the autoscaling group, whichever number is lower. For example, if the minimum size is 1 and the maximum size is 3, then the default is 1. However, if the minimum size is 4 and the maximum size is 4, then the default is 3. You can specify a number between 0 and 9999.
  • Pause time – Specify the amount of time the AWS CloudFormation service waits after it has completed updates to one batch of instances before it continues on to the next batch. The pause time accounts for the fact that instances are not immediately available after they start running. The environment's instance type and container type determine the default pause time, but you can override the recommended value. A valid pause time can range from 0 seconds to 1 hour.

The Pause time boxes let you specify how long AWS CloudFormation waits after it has completed updates to one batch of instances before it continues on to the next batch. This table shows the default values for each instance type and container combination. The values are expressed in ISO8601 duration format in the form: PT#H#M#S, where each # is the number of hours, minutes, and/or seconds, respectively.

How can we configure RDS with Beanstalk?

If you didn't use the Create New Application wizard to add an RDS DB instance to your environment, you can use an application's Configuration page to do so.

How can we create an Amazon RDS database and associate it with your existing environment?

  1. Select if you want to create a blank Amazon RDS DB or create one from a snapshot. If you choose to create a database from a snapshot, then select a snapshot from the Snapshot list.
  2. For DB Engine, select a database engine.
  3. For Instance Class, select a database instance class. For information about the DB instance classes, go to http://aws.amazon.com/rds/.
  4. For Allocated Storage, type the desired amount space (in GB). In some cases, allocating a higher amount of storage for your DB instance than the size of your database can improve IO performance. For information about storage allocation, go to Features.
  5. For Master Username, use alphanumeric characters to type a name that you will use to log on to your DB instance with all database privileges.
  6. For Master Password, type 8 to 16 printable ASCII characters (excluding /, \, and @) for your master user password.
  7. For Deletion Policy, select whether to create a snapshot of your database or delete it if you terminate your AWS Elastic Beanstalk environment. The default is Delete, which deletes your database and discards your data if you terminate your environment.
  8. Select whether to configure your database across multiple Availability Zones or just one. Running your database instance in multiple Availability Zones safeguards your data in the unlikely event of a database instance component failure or service health disruption in one Availability Zone.
  9. Click Save.

AWS Elastic Beanstalk updates the environment and creates the Amazon RDS database. After the update is complete, you can view the databases by going to the Configuration page.

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html and http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.rds.html#create_deploy_Java.rds.newDB

How can we configure Beanstalk to use SNS?

AWS Elastic Beanstalk can use the Amazon Simple Notification Service (Amazon SNS) to notify you of important events affecting your application. You can enable Amazon SNS notifications by editing the Notification settings on the environment's Configuration page.

How can we access the JVM container configurations for your AWS Elastic Beanstalk application?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the AWS Elastic Beanstalk console applications page, click the environment that you want to configure.
  3. In the Overview section of the environment dashboard, click Edit.
  4. On the Configuration page, click Edit (the tool icon) for Software Configuration in order to edit the container settings.

The heap size in the Java Virtual Machine affects how many objects can be created in memory before garbage collection—a process of managing your application's memory—occurs. You can specify an initial heap size and a maximum heap size. A larger initial heap size allows more objects to be created before garbage collection occurs, but it also means that the garbage collector will take longer to compact the heap. The maximum heap size specifies the maximum amount of memory the JVM can allocate when expanding the heap during heavy activity.

You can set the initial and the maximum JVM heap sizes using the Initial JVM Heap Size (-Xms argument) and Maximum JVM Heap Size (-Xmx argument) boxes. The available memory is dependent on the Amazon EC2 instance type. For more information about the Amazon EC2 instance types available for your AWS Elastic Beanstalk environment, go to Instance Families and Types in the Amazon EC2 User Guide.

The permanent generation is a section of the JVM heap that is used to store class definitions and associated metadata. To modify the size of the permanent generation, type the new size in the Maximum JVM PermGen Size (-XX:MaxPermSize argument) box.

Full documentation of JVM is beyond the scope of this guide; for more information on JVM garbage collection, go to Tuning Garbage Collection with the 1.4.2 Java Virtual Machine.

How can we enable log file rotation to S3?

AWS Elastic Beanstalk can copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application on an hourly basis. To enable this feature, select Enable log file rotation to Amazon S3.

What is the definition of Environmental Property?

The environment properties lets you specify environment properties on the Amazon EC2 instances that are running your application. Environment properties are specific to your application environment and are not actual (shell) environment variables. More specifically, PARAM1, PARAM2, etc. are system properties passed into the JVM at startup using the -D flag. You can use them to pass database connection strings, security credentials, or other information that you don't want to hard-code into your application. Storing this information in environment properties can help increase the portability and scalability of your application. You do not need to recompile your source code when you move between environments. You can acquire them with System.getProperty(name). For more information on using and accessing custom environment properties, see Using Custom Environment Properties with AWS Elastic Beanstalk.

You can configure the following environment properties:

  • Specify AWS credentials using the AWS_ACCESS_KEY_ID and AWS_SECRET_KEY boxes. For nonlegacy containers, use instance profiles so that your application can use temporary security credentials to access AWS resources. To learn more, see Granting Permissions to Users and Services Using IAM Roles.
  • Specify a connection string to an external database (such as Amazon RDS) by entering it in the JDBC_CONNECTION_STRING box. For more information on how to set your JDBC_CONNECTION_STRING, see Using Custom Environment Properties with AWS Elastic Beanstalk.
  • Specify up to five additional environment properties by entering them in the PARAM boxes. Environment properties can contain any printable ASCII character except the grave accent (`, ASCII 96) and cannot exceed 200 characters in length.

How can we view and connect to Amazon EC2 instances for an environment?

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. From the region list, select a region.
  3. In the navigation (left) pane of the console, click Load Balancers.
  4. Load balancers created by AWS Elastic Beanstalk will have a awseb in the name. Find the load balancer for your environment and click it.
  5. Click the Instances tab in the bottom pane of the console window. A list of the instances that the load balancer for your AWS Elastic Beanstalk environment uses is displayed. Make a note of an instance ID that you want to connect to.
  6. Click the Instances link in the left side of the Amazon EC2 console, and find your instance ID in the list.
  7. Right-click the instance ID for the Amazon EC2 instance running in your environment's load balancer, and then select Connect from the context menu.
  8. Make a note of the instance's public DNS address on the Description tab.
  9. To connect to an instance running Linux, use the SSH client of your choice to connect to your instance and type ssh -i .ec2/mykeypair.pem ec2-user@<public-DNS-of-the-instance>

How can we take a snapshot and view logs?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the AWS Elastic Beanstalk console applications page, click the name of the environment that you want to view logs for.
  3. In the navigation menu, click Logs. The Logs page lists the snapshot logs for your environment.
    • To get the latest snapshot, click Snapshot Logs. This action takes a snapshot of the logs for your AWS Elastic Beanstalk application. It takes several seconds to retrieve the log files. You may need to click the Refresh button to see the contents of the log files.
  4. To view the contents of a log file, click View log file. A web page displays the text output of the log file snapshot. A copy of the tail logs is placed in the Amazon S3 bucket associated with your application for 15 minutes.

How can we configure our environment to publish logs to Amazon S3?

You can configure your environment so that the logs from the Amazon EC2 instances running your applications are copied by AWS Elastic Beanstalk to the Amazon S3 bucket associated with your application.

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the AWS Elastic Beanstalk console applications page, click the environment that you want to configure.
  3. In the Overview section of the environment dashboard, click Edit.
  4. On the Configuration page, click for Software Configuration in order to edit the container settings.
  5. Select Enable log file rotation to Amazon S3.

How can we customize our environment using configuration files?

Customizing your AWS Elastic Beanstalk environment when you deploy your application requires two steps:

  1. Create a configuration file with the extension .config (e.g., myapp.config) and place it in an .ebextensions top-level directory of your source bundle. You can have multiple configuration files in your .ebextensions directory. These files are executed in alphabetical order. For example, .ebextensions/01run.config is executed before .ebextensions/02do.config. Configuration files should conform to YAML or JSON formatting standards.
  2. Deploy your application version. You can take a snapshot of the logs to view the output of the steps during deployment. For instructions on how to view the logs, see Working with Logs. If any error occurs during the deployment process, AWS Elastic Beanstalk does not deploy the new application version. If you deployed an older application version, you will continue to see it running.

How can we customize the software on EC2 Instances Running Linux?

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

How can we configure our environment to use Eb?

Eb is a command line interface that enables you to deploy applications quickly and more easily using Git. See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-cw.html

How can we customize environment resources?

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html

How can we use a domain hosted by a third party?

If you host a domain name with a third party, you can use that domain name for your AWS Elastic Beanstalk application. Because the IP address of the elastic load balancer is not fixed, you should not associate your domain name with your load balancer's IP address. Instead, you should create a CNAME with your DNS provider, and then map the CNAME to your Elastic Beanstalk URL. Make sure you also forward your unqualified domain name, (i.e., example.com), to your qualified domain name (i.e., www.example.com) so that when users type example.com and www.example.com, they both map to your AWS Elastic Beanstalk application. Check your DNS provider's instructions for mapping your domain name to your AWS Elastic Beanstalk URL.

For example, if your AWS Elastic Beanstalk URL is http://foobar.elasticbeanstalk.com, then you would do the following high level steps:

  1. Create a CNAME for your www record that maps to foobar.elasticbeanstalk.com.
  2. Forward example.com to www.example.com.

How can we view the Elastic Beanstalk URL for our application?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select the region that includes the environment that you want to work with.
  3. From the AWS Elastic Beanstalk console applications page, click the name of the environment that you want to view the URL for. In the environment dashboard, the URL for the environment is displayed next to the name of the environment.

How can we use a domain hosted by AWS Route 53?

Amazon Route 53 is a highly available and scalable DNS web service. If you host a domain name using Amazon Route 53, you can use that domain name for your AWS Elastic Beanstalk application. Given how the DNS protocol works, there is no way to refer your elastic load balancer or Amazon EC2 instance from the root (also known as the apex) of the domain. For instance, you can create a DNS entry that maps http://www.example.com to an elastic load balancer or EC2 instance, but you cannot do the same for http://example.com. Amazon Route 53 enables you to map the apex (such as example.com) of a hosted zone to your elastic load balancer or EC2 instance using an alias record. When Amazon Route 53 encounters an alias record, it looks up the records associated with the target DNS name in the alias, and returns the IP addresses from that name. The following procedures walk you through mapping your root domain and subdomains to your elastic load balancer or EC2 instance in your AWS Elastic Beanstalk environment.

  1. Follow the Amazon Route 53 Getting Started Guide instructions to sign up for Route 53, create a hosted zone, and then update your name server records with your registrar.
  2. Get the value of the hosted zone ID for your load balancer.
    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
    2. From the region list, select a region.
    3. In the Navigation pane, click Load Balancers
    4. Select the load balancer associated with your AWS Elastic Beanstalk application. To verify you have the correct load balancer for your environment, check the instance name in the Instances tab. The instance name should be your environment name. Your hosted ID will appear in the Load Balancer details pane on the Description tab. Make a note of your hosted ID.
    5. Create alias resource record sets in your hosted zone for your root domain and subdomain. For instructions, go to How to Create an Alias Resource Record Set in the Amazon Route 53 Developer Guide.
    6. Your root domain and subdomain are now mapped to your AWS Elastic Beanstalk elastic load balancer. Type your domain name in your web browser to verify it worked.

If you rebuild your environment, launch a new environment, or swap your environment URL, you will need to map your root domain to the load balancer in your new environment.

How can we map our root domain and subdomains to a single Amazon EC2 instance?

  1. Follow the instructions to sign up for Route 53 and create a hosted zone in Getting Started: Creating a Domain that Uses Route 53 in the Amazon Route 53 Developer Guide.
  2. Get the Elastic IP for your EC2 instance.
    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
    2. From the region list, select a region.
    3. In the Navigation column, click Instances.
    4. Select the instance associated with your AWS Elastic Beanstalk application. Your Elastic IP address will appear in the details pane on the Description tab. Make a note of your Elastic IP address.
    5. Create resource record sets in your hosted zone for your root domain and subdomains. For a single EC2 instance, create an A record by specifying the Elastic IP address of the instance. For instructions, see Step 4: Create Resource Record Sets in your Route 53 Hosted Zone in the Amazon Route 53 Developer Guide.
    6. Update your registrar's name server records. For instructions, see Step 5: Update the Registrar's Name Server Records in the Amazon Route 53 Developer Guide.
    7. Your root domain and subdomain are now mapped to the Elastic IP of your EC2 instance in AWS Elastic Beanstalk. Type your domain name in your web browser to verify it worked.

How can we configure HTTPS for our AWS Elastic Beanstalk Environment?

You can configure your AWS Elastic Beanstalk environment to use HTTPS for your application. Configuring HTTPS ensures traffic encryption for client connections to the load balancer.

  1. Create a Custom Domain: You need to create a custom domain name to obtain a digitally signed SSL certificate. When obtaining a signed SSL certificate, the Certificate Authority (CA) checks the domain name to ensure that you are the owner of that domain. Because your AWS Elastic Beanstalk URL contains elasticbeanstalk.com, you will not be able to obtain a certificate for this domain name. To create a custom domain name, you can use Amazon Route 53 or a third party. For instructions, see Using Custom Domains with AWS Elastic Beanstalk.
  2. Create and Upload an SSL Certificate to AWS IAM: After you have created your custom domain, you use AWS Identity and Access Management (AWS IAM) to create and upload your certificate. This enables you to use your certificate with AWS services such as AWS Elastic Beanstalk. The following steps walk you through an example of how to create and upload your SSL certificate to AWS IAM. For more information, go to Creating and Uploading Server Certificates in the AWS Identity and Access Management Using IAM User Guide.

How can we create a private key?

openssl genrsa 1024 > privatekey.pem

How can we create a CSR?

openssl req -new -key privatekey.pem -out csr.pem

How can we generate a self-signed certificate?

openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt

How can we upload a signed certificate?

iam-servercertupload -b server.crt -k privatekey.pem -s server -v

You should see an Amazon Resources Name (ARN) for your SSL certificate similar to the following:

arn:aws:iam::123456789012:server-certificate/cert

If you have a certificate that results in an error when you upload it, ensure that it meets the criteria, and then try uploading it again. To see sample certificates that are valid with IAM, go to Sample Certificates in the AWS Identity and Access Management Using IAM User Guide.

What are the basic steps to configure Beanstalk to use HTTPS?

  1. Install OpenSSL somewhere
  2. Create a private key
  3. Create a CSR
  4. Submit the CSR to Certificate Authority and pay for the SSL certificate
  5. Upload the certificate
  6. Update Your Elastic Beanstalk Environment to Use HTTPS

How can we update our Elastic Beanstalk environment to use HTTPS?

After you receive your Amazon Resources Name (ARN), you need to update your elastic load balancer configuration settings in your Elastic Beanstalk environment with the following information:

  • HTTP port — set this port to OFF or 80
  • HTTPS port — set this port to 443 or 8443
  • SSL certificate ID — set this to your ARN

What to do if you receive the Elastic Load Balancer awseb-<yourapp> Cannot Be Found error?

This event usually occurs when an account owner or other authorized user manually removes the Elastic Load Balancer. To resolve this issue, you need to rebuild your environment.

  1. From the AWS Elastic Beanstalk console applications page, click the environment name that you want to rebuild.
  2. Click Actions and the select Rebuild Environment.

What to do when you encounter the "EC2 Instance Launch Failure. Waiting for a New EC2 Instance to Launch" error?

This event occurs when an Amazon EC2 instance fails to launch. If this event occurs, try one or both of the following:

How can we use CloudFront with Beanstalk?

CloudFront works seamlessly with Amazon S3. After you create and deploy your AWS Elastic Beanstalk you can sign up for Amazon CloudFront and start using Amazon CloudFront to distribute your content. Create your distribution from a custom origin, and use an AWS Elastic Beanstalk domain name. To get started using Amazon CloudFront, go to the Amazon CloudFront Developer Guide.

How can we use ElasticCache with Beanstalk?

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.ElastiCache.html

How can we use RDS with Beanstalk?

If you plan to use Amazon RDS, it is advisable to configure Amazon RDS across multiple Availability Zones. This enables a synchronous standby replica of your database to be provisioned in a different Availability Zone. To keep both databases in sync, updates to your database instance are synchronously replicated across Availability Zones. In case of a failover scenario, the standby is promoted to be the primary and will handle the database operations. Running your database instance in multiple Availability Zones safeguards your data in the unlikely event of a database instance component failure or service health disruption in one Availability Zone.

The instructions for configuring your AWS Elastic Beanstalk application with Amazon RDS depend on the programming language you use.

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.RDS.html and Using Amazon RDS and MySQL Connector/J

How can we use AWS Elastic Beanstalk with Amazon Route 53 to Map Your Domain to Your Load Balancer?

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.Route53.html

How can we use AWS Elastic Beanstalk with Amazon S3?

Amazon S3 is a simple web service that provides highly durable, fault-tolerant data storage. Behind the scenes, Amazon S3 stores objects redundantly on multiple devices across multiple facilities in an Amazon S3 Region. In the unlikely event of a failure in an Amazon Web Service data center, you will still have access to your data. AWS Elastic Beanstalk automatically signs you up for Amazon S3 when you sign up for AWS Elastic Beanstalk. When you create your application and deploy it to AWS Elastic Beanstalk your application will be automatically uploaded to an Amazon S3 bucket. To learn more about Amazon S3, go to the Amazon Simple Storage Service (Amazon S3) product page. For code samples that demonstrate how to retrieve objects directly from S3, see Getting Objects.

How can we use AWS Elastic Beanstalk with AWS Identity and Access Management (IAM)?

AWS Identity and Access Management (IAM) helps you securely control access to your AWS resources. IAM can also keep your account credentials private. With IAM, you can create multiple IAM users under your AWS account. In some cases, you can also enable access to resources across AWS accounts. Without IAM, however, you must either create multiple AWS accounts, or users must share the security credentials of a single AWS account. In addition, without IAM, you cannot control the tasks a particular user or system can do and what AWS resources they can use. For more information about IAM, see Getting Started in Using IAM.

IAM is available with AWS Elastic Beanstalk. You do not need to sign up separately to use IAM. See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.html

How can we grant permissions to IAM Users?

An IAM user can be an individual, system, or application that interacts with AWS. You can grant permissions to users by using attaching a policy to each user or by using a group policy. For more information, see IAM Users and Groups in Using IAM. To learn how to use policies to control access to specific resources, see Using Policies to Control Access to Resources.

How can we grant permissions to users and services using IAM roles?

IAM roles have permissions that you can delegate to another entity, such as an IAM user or AWS service. The entity who assumes the role gets temporary security credentials with the same permissions as the role to make AWS API calls. You can use roles to temporarily grant entities permissions to access resources in your AWS account without sharing your long-term credentials or defining permissions for those entities.

You might want to use IAM roles if you want to do any of the following:

  • Allow AWS Elastic Beanstalk to rotate your logs to Amazon S3. AWS Elastic Beanstalk can create a default instance profile for you when you create or update your environment. For instructions using the Elastic Beanstalk console, see Managing and Configuring Applications and Environments Using the Console, CLI, and APIs. For instructions using eb, see Getting Started with Eb.
  • Grant permissions to applications running on Amazon EC2 instances access to AWS resources (such as Amazon DynamoDB).

How can we grant permissions to applications running in AWS Elastic Beanstalk?

  1. Create an IAM role or use the default role provided by AWS Elastic Beanstalk when you deploy your application.
  2. Write a policy that defines who can assume the role (the trusted entities). For AWS Elastic Beanstalk, grant Amazon EC2 permission to assume the role.
  3. Attach a policy to the role that grants or denies the application permission to perform certain actions on specific AWS resources.
  4. Launch your AWS Elastic Beanstalk environment using the instance profile associated with the role. To launch an environment with a role, you must have permission to perform the IAM passrole action. If you use the AWS Management Console to create and manage roles, instance profiles are automatically managed for you. If you use the IAM API or CLI to create and manage roles, you must create instance profiles for each role. A role can be associated with many instance profiles, but an instance profile can be associated with only one role. For more information about instance profiles, go to Instance Profiles in the AWS Identity and Access Management Using IAM.

How can we use IAM Policies to Control Access to Resources?

There are two ways to control access to AWS resources:

  • Use a policy template.
  • Create a custom policy that allows or denies permissions to perform specific actions on specific resources. A custom policy gives you the flexibility to specify exactly what actions can be performed on what resources.

To learn how to apply a AWS Elastic Beanstalk policy template to a user or group, see Using Policy Templates to Control Access to All AWS Elastic Beanstalk Resources.

To learn more about custom policies, and how to allow or deny permissions to perform specific actions on AWS Elastic Beanstalk resources, see Creating Policies to Control Access to Specific AWS Elastic Beanstalk Resources.

To learn how to use IAM roles with AWS Elastic Beanstalk, see Using IAM Roles with AWS Elastic Beanstalk.

For more information about permissions, see Permissions and Policies in Using IAM.

How can we use Policy Templates to control access to all AWS Elastic Beanstalk resources?

AWS Elastic Beanstalk provides two policy templates that enable you to assign full access or read-only access to all AWS Elastic Beanstalk resources. You can attach the policy templates to users or groups. You should use these templates if you want to grant broad permissions for all AWS Elastic Beanstalk in your AWS account. If you want to control permissions for specific resources, you need to create the policy.

The following table describes each policy template:

  • AWS Elastic Beanstalk Full Access: This template allows the user to create, modify, and delete applications, application versions, configuration settings, environments, and their underlying resources, including access required by AWS Elastic Beanstalk to provision and manage underlying resources (Elastic Load Balancing, Auto Scaling, Amazon EC2, Amazon SNS, CloudWatch, Amazon S3, Amazon RDS, and AWS CloudFormation (for non-legacy container types)) used by an environment.
  • AWS Elastic Beanstalk Read Only Access: This template allows the user to view applications and environments but not to perform any operations on them. It provides read-only access to all applications, application versions, events, and environments.

How can we apply a policy template to a user or group?

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  2. In the left pane, click Users or Groups, as appropriate.
  3. In the Users or Groups pane, click the user or group that you want to apply the policy template to. Or, click Create New Users or Create New Group to create new users or a group.
  4. Under the user or group name, click the Permissions tab.
  5. Click Attach User Policy for a user or Attach Policy for a group, as appropriate.
  6. On the Manage Policy page, click Select Policy Template.
  7. Locate the policy that you want to assign, and then click the corresponding Select button.
  8. Review the policy document, and then click Apply Policy.

How can we create Policies to Control Access to Specific AWS Elastic Beanstalk Resources?

You can create your own IAM policy to allow or deny specific AWS Elastic Beanstalk API actions on specific AWS Elastic Beanstalk resources. To put the policy into effect, you attach it to a user or group using the IAM console, command line interface, or API. For more information about attaching a policy to a user or group, see Managing IAM Policies in Using AWS Identity and Access Management.

If you use the AWS Management Console to create and manage roles, instance profiles are automatically managed for you. If you use the IAM API or CLI to create and manage roles, you must create instance profiles for each role. A role can be associated with many instance profiles, but an instance profile can be associated with only one role. For more information about instance profiles, go to Instance Profiles in the AWS Identity and Access Management Using IAM.

An IAM policy contains policy statements that describe the specific permissions you want to grant. When you create a policy statement for AWS Elastic Beanstalk, there are four parts of a statement that you need to know how to use:

  • Effect specifies whether to allow or deny the actions in the statement.
  • Action specifies the actions you want to control. To specify AWS Elastic Beanstalk actions, the action name must be prefixed with the lowercase string elasticbeanstalk. You use wildcards to specify all actions related to AWS Elastic Beanstalk. The wildcard "*" matches zero or multiple characters. For example, to grant all create action permissions, you can specify elasticbeanstalk:create* in your IAM policy. If your policy uses a wildcard to specify all actions instead of explicitly listing each action, be aware that if an update to AWS Elastic Beanstalk were to add any new actions, this policy would automatically give the grantee access to those new actions. For a complete list of AWS Elastic Beanstalk actions, see the API action names in the AWS Elastic Beanstalk API Reference. For more information about permissions and policies, go to Permissions and Policies in Using AWS Identity and Access Management. Users with permission to use specific AWS Elastic Beanstalk API actions can perform those actions. Certain operations, such as creating an environment, may require additional permissions to perform those actions. To check if an API action depends on permissions to other actions and to ensure all required permissions are assigned, use the information in section Resources and Conditions for AWS Elastic Beanstalk Actions.
  • Resource specifies the resources that you want to control access to. To specify AWS Elastic Beanstalk resources, you list the Amazon Resource Name (ARN) of each resource. For more information, see Amazon Resource Name (ARN) Format for AWS Elastic Beanstalk. Each AWS Elastic Beanstalk action operates on a specific resource. For example, the UpdateApplicationVersion action operates on application versions, which you would specify as one or more version resources. For more information, see Amazon Resource Name (ARN) Format for AWS Elastic Beanstalk. To specify multiple ARNs, you can list each resource's ARN or use the "*" wildcard, which matches zero or multiple characters.
  • Condition specifies restrictions on the permission granted in the statement. As discussed earlier, an action operates on a specific resource. However, that action may have dependencies on other AWS Elastic Beanstalk resources such as where the action occurs (for example, creating an environment within an application) or which other resources the action needs access to in order to complete its operation (for example, updating an environment from a configuration template or application version). For more information, see Resources and Conditions for AWS Elastic Beanstalk Actions.

IAM policies are expressed in JSON format. For information about the structure of IAM policies and statements, see Basic Policy Structure in Using AWS Identity and Access Management. The following example policy contains three sets of statements that enable a user who has this policy to call the CreateEnvironment action to create an environment whose name begins with Test in the application My First Elastic Beanstalk Application using the application version First Release. The policy also allows the user to perform actions on the resources required to create the environment. The CreateEnvironmentPerm statement allows the elasticbeanstalk:CreateEnvironment action to create an environment with the constraints specified above. The AllNonResourceCalls statement allows elasticbeanstalk:CreateEnvironment to perform the AWS Elastic Beanstalk actions required to create the environment. The OtherServicePerms statement allows elasticbeanstalk:CreateEnvironment to call the appropriate actions to create resources in other AWS services to complete the creation of the environment.

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.policies.html

How can we use IAM Roles with AWS Elastic Beanstalk?

You can use IAM roles to control what actions and AWS services your Elastic Beanstalk application can access. With roles, you don't have to share long-term credentials or define permissions for each entity that requires access to a resource. Use IAM roles if your application requires access to AWS resources such as Amazon DynamoDB or if you want AWS Elastic Beanstalk to rotate your logs to Amazon S3.

How can we grant IAM Users Permissions to Create and Pass IAM Roles?

To use IAM roles with AWS Elastic Beanstalk, you need to have the appropriate permissions so that AWS Elastic Beanstalk can create a default role and instance profile for you, or to view the list of instance profiles available in your environment. If you tried to create or update your environment to use an instance profile, but you received an error, the error might have occurred because you do not have the correct permissions. Your account administrator should allow the following actions:

"iam:AddRoleToInstanceProfile",
"iam:CreateInstanceProfile",
"iam:CreateRole",
"iam:PassRole",
"iam:ListInstanceProfiles"

You require the create role, create instance profile, and add to instance profile actions in order to create a role. The list instance profiles actions allows you to list the instance profiles in the AWS account, and the pass role action allows you to associate a role to an environment.

The following example shows one statement that gives a broad set of permissions to AWS products that AWS Elastic Beanstalk uses to manage applications and environments and includes permissions to create an instance profile and view a list of available instance profiles.

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "elasticbeanstalk:*",
        "ec2:*",
        "elasticloadbalancing:*",
        "autoscaling:*",
        "cloudwatch:*",
        "s3:*",
        "sns:*",
        "cloudformation:*",
        "rds:*",
        "iam:AddRoleToInstanceProfile",
        "iam:CreateInstanceProfile",
        "iam:CreateRole",
        "iam:PassRole",
        "iam:ListInstanceProfiles"
      ],
      "Resource": "*"
    }
  ]
}

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.roles.aeb.html

What does Amazon Resource Name (ARN) Format for AWS Elastic Beanstalk look like?

You specify a resource for an IAM policy using that resource's Amazon Resource Name (ARN). For AWS Elastic Beanstalk, the ARN has the following format.

arn:aws:elasticbeanstalk:region:accountid:resourcetype/resourcepath
  • region is the region the resource resides in (for example, us-east-1).
  • accountid is the AWS account ID, with no hyphens (for example, 123456789012)
  • resourcetype identifies the type of the AWS Elastic Beanstalk resource—for example, environment. See the table below for a list of all AWS Elastic Beanstalk resource types.
  • resourcepath is the portion that identifies the specific resource. An AWS Elastic Beanstalk resource has a path that uniquely identifies that resource. See the table below for the format of the resource path for each resource type. For example, an environment is always associated with an application. The resource path for the environment myEnvironment in the application myApp would look like this: myApp/myEnvironment

AWS Elastic Beanstalk has several types of resources you can specify in a policy. The following table shows the ARN format for each resource type and an example.

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.policies.arn.html

An environment, application version, and configuration template are always contained within a specific application. You'll notice that these resources all have an application name in their resource path so that they are uniquely identified by their resource name and the containing application. Although solution stacks are used by configuration templates and environments, solution stacks are not specific to an application or AWS account and do not have the application or AWS account in their ARNs.

What happens when CloudFormation update its stack?

When AWS CloudFormation updates a stack, it gets new property settings for the current resources in the stack by using the template that you submit. AWS CloudFormation updates only the resources that have changes specified in the template. AWS CloudFormation does not update resources that have no changes, and those resources will continue to run without disruption during the update process. Updates to resources are handled differently depending on the type of resource and, in some cases, depending on the nature of a particular resource property. AWS CloudFormation uses one of the following techniques to update the resource:

  • Update with no interruption. AWS CloudFormation updates the resource without disrupting operation of that resource and without changing the resource's physical name. For example, if you update any properties on an AWS::CloudWatch::Alarm resource, AWS CloudFormation updates the alarm's configuration and, during the update, the alarm's operation continues without disruption.
  • Reconfiguration with some interruption. AWS CloudFormation updates the resource with some interruption. Some resources may experience some interruption during the process of applying property changes to those resources but they will retain their physical names.
  • Replacement. AWS CloudFormation updates the resource by recreating the resource. Some resources require creating a new resource with the property changes and generating a new physical name. AWS CloudFormation creates the replacement resource first, changes references from other dependent resources to point to the replacement resource, and then deletes the old resource.

Whether or not a change in a resource causes an interruption in service depends on the resource itself and on the type of change you're making to it. To learn more about updating a particular resource, see the documentation associated with that resource and in the AWS Resource Types Reference, where the effects of updating a resource are listed per property.

You should be aware of how each resource change will affect your stack before making a change.

Depending on the technique used to modify each updated resource in your stack, you can make good decisions about when it's best to modify resources to reduce the impact of such changes on your application. In particular, you should plan carefully when resources must be replaced during an update.

How can we create and use a customized AMI with Beanstalk?

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.
  2. From the region list, select a region.
  3. Launch your AWS Elastic Beanstalk application. For more information on how to launch an AWS Elastic Beanstalk application, go to the Getting Started Using AWS Elastic Beanstalk.
  4. Find the AMI ID used by AWS Elastic Beanstalk to launch your application. This information can be viewed in the AWS Elastic Beanstalk Edit Configuration dialog box.
  5. 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 AWS Elastic Beanstalk.
    1. Open the Amazon EC2 console.
    2. Click the Launch Instance button. The Request Instances Wizard appears.
    3. Click the My AMIs tab.
    4. Select All Images from the Viewing drop-down list.
    5. Enter the AMI ID that AWS Elastic Beanstalk used to launch your application in the text box to the right of the Viewing drop-down list and wait for the AMI to appear in the list.
    6. Click the Select button next to the AMI in the list to continue.
    7. Continue using the Amazon EC2 Request Instances Wizard to launch the AWS Elastic Beanstalk AMI that you want to customize. When launching the instance using the AWS Management Console, make sure you create or specify a key pair, and that you select your EC2 security group for your AWS 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. You must leave the AWS Elastic Beanstalk host manager running on your instance. After you are running on your own custom AMI, you will no longer receive any automated updates to the operating system, software stack, or the AWS Elastic Beanstalk host manager.
    8. 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.
    9. 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 AWS 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. See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html
    10. 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.
    11. 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.
    12. To use your custom AMI, specify your custom AMI ID in the Custom AMI ID text box in the AWS Elastic Beanstalk Edit Configuration dialog box. Existing instances will be replaced with new instances launched from the new custom AMI.

How can we customize Beanstalk instance?

packages: 
  yum:
    libmemcached: [] 
    ruby-devel: []
    gcc: []
sources:  
  /etc/myapp: http://s3.amazonaws.com/mybucket/myobject

The above command downloads a .zip file from an Amazon S3 bucket and unpacks it into /etc/myapp

You can use the commands key to execute commands on the EC2 instance. The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted.

commands:
  test_command: 
    command: <command to run>
    cwd: <working directory>
    env: 
      <variable name>: <variable value>
    ignoreErrors: true

You can use the container_commands key to execute commands for your container. The commands in container_commands are processed in alphabetical order by name. They run after the application and web server have been set up and the application version file has been extracted, but before the application version is deployed. They also have access to environment variables such as your AWS security credentials. Additionally, you can use leader_only. One instance is chosen to be the leader in an Auto Scaling group. If the leader_only value is set to true, the command runs only on the instance that is marked as the leader.

container_commands:
 <name of container_command>:
    command: <command to run>
    leader_only: true
 <name of container_command>:
    command: <command to run>

You can use the services key to define which services should be started or stopped when the instance is launched. The services key also allows you to specify dependencies on sources, packages, and files so that if a restart is needed due to files being installed, AWS Elastic Beanstalk takes care of the service restart.

services: 
  sysvinit:
    <name of service>:
      enabled: true
      ensureRunning: true
      files: "<file name>"
      sources: "<directory>"    
      packages: 
        <name of package manager>:
          <package name>: <version>
      commands: 
        <name of command>:

Option_settings enables you to modify the Elastic Beanstalk configuration and define variables that can be retrieved from your application using environment variables. The following table displays the namespaces that are supported for each container type. Some namespaces allow you to extend the number of parameters, and specify the parameter names. For a list of configuration settings, see Option Values.

option_settings:
  - namespace:  aws:elasticbeanstalk:container:tomcat:jvmoptions
    option_name:  Xmx
    value:  256m
  - option_name: myparam1
    value: somevalue

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License