

# Managing Elastic Beanstalk applications
<a name="applications"></a>

This chapter describes how to manage and configure your Elastic Beanstalk applications. The first step in using AWS Elastic Beanstalk is to create an application, which represents your web application in AWS. In Elastic Beanstalk an application serves as a container for the environments that run your web app and for versions of your web app's source code, saved configurations, logs, and other artifacts that you create while using Elastic Beanstalk.

**To create an application**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose **Create application**.

1. Use the on-screen form to provide an application name.

1. (Optional) Provide a description, and add tag keys and values.

1. Choose **Create**.

After creating the application, the console prompts you to create an environment for it. For detailed information about all of the options available, see [Creating an Elastic Beanstalk environment](using-features.environments.md).

If you no longer need an application, you can delete it.

**Warning**  
Deleting an application terminates all associated environments and deletes all application versions and saved configurations that belong to the application.

**To delete an application**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then select your application on the list.

1. Choose **Actions**, and then choose **Delete application**.

**Topics**
+ [Elastic Beanstalk application management console](applications-console.md)
+ [Managing application versions](applications-versions.md)
+ [Create an Elastic Beanstalk application source bundle](applications-sourcebundle.md)
+ [Using the EB CLI with AWS CodeBuild](eb-cli-codebuild.md)
+ [Tagging applications](applications-tagging.md)
+ [Tagging Elastic Beanstalk application resources](applications-tagging-resources.md)

# Elastic Beanstalk application management console
<a name="applications-console"></a>

This topic explains how you can use the AWS Elastic Beanstalk console to manage applications, application versions, and saved configurations.

**To access the application management console**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

   The application overview page shows a list with an overview of all environments associated with the application.

1. You have a few ways to continue:

   1. From the **Actions** drop-down menu, you can choose one of the application management actions: **Create environment**, **Delete application**, **View application versions**, **View saved configurations**, **Restore terminated environment**.

      To launch an environment in this application, you can directly choose **Create environment**. For details, see [Creating an Elastic Beanstalk environment](using-features.environments.md).

   1. The page lists the environment name next to applications that are deployed to an environment. Choose an environment name to go to the [environment management console](environments-console.md) for that environment, where you can configure, monitor, or manage the environment.

   1. When you select an application from the list, the left navigation pane lists the application.
      +  Choose **Application versions** following the application name in the navigation pane to view and manage the application versions for your application. 

        An application version is an uploaded version of your application code. You can upload new versions, deploy an existing version to any of the application's environments, or delete old versions. For more information, see [Managing application versions](applications-versions.md). 
      +  Choose **Saved configurations** following the application name in the navigation pane to view and manage configurations saved from running environments. 

        A saved configuration is a collection of settings that you can use to restore an environment's settings to a previous state, or to create an environment with the same settings. For more information see [Using Elastic Beanstalk saved configurations](environment-configuration-savedconfig.md). 

# Managing application versions
<a name="applications-versions"></a>

This topic explains application versions and how to create and manage them.

Elastic Beanstalk creates an application version whenever you upload source code. This usually occurs when you create an environment or upload and deploy code using the [environment management console](environments-console.md) or [EB CLI](eb-cli3.md). Elastic Beanstalk deletes these application versions according to the application's lifecycle policy and when you delete the application. For details about application lifecycle policy, see [Configuring application version lifecycle settings](applications-lifecycle.md).

You can also upload a source bundle without deploying it from the [application management console](applications-console.md) or with the EB CLI command **[**eb appversion**](eb3-appversion.md)**. Elastic Beanstalk stores source bundles in Amazon Simple Storage Service (Amazon S3) and doesn't automatically delete them.

You can apply tags to an application version when you create it, and edit tags of existing application versions. For details, see [Tagging application versions](applications-versions-tagging.md).

## Creating application versions
<a name="applications-versions.creating"></a>

You can also create a new application version using the EB CLI. For more information, see [**eb appversion**](eb3-appversion.md) in the *EB CLI commands* chapter.

**Note**  
Over time, your application can accumulate many application versions. To save storage space and avoid hitting the [application version quota](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_elastic_beanstalk), it's a good idea to delete application versions that you no longer need. 

The file you specify in the following procedure is associated with your application. You can deploy the application version to a new or existing environment.

**To create a new application version**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

1. In the navigation pane, find your application's name and choose **Application versions**.

1. Choose **Upload**. Use the on-screen form to upload your application's [source bundle](applications-sourcebundle.md).
**Note**  
The source bundle's file size limit is 500 MB.

1. Optionally, provide a brief description, and add tag keys and values.

1. Choose **Upload**.

## Deleting application versions
<a name="applications-versions.deleting"></a>

You can also delete an application version using the EB CLI. For more information, see [**eb appversion**](eb3-appversion.md) in the *EB CLI commands* chapter.

**Note**  
Deleting an application version doesn't affect environments currently running that version.

You can also configure Elastic Beanstalk to delete old versions automatically by configuring application version lifecycle settings. If you configure these lifecycle settings, they're applied when you create new application versions. For example, if you configure a maximum of 25 application versions, Elastic Beanstalk deletes the oldest version when you upload a 26th version. If you set a maximum age of 90 days, any versions older than 90 days are deleted when you upload a new version. For details, see [Configuring application version lifecycle settings](applications-lifecycle.md).

**To delete an application version**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

1. In the navigation pane, find your application's name and choose **Application versions**.

1. Select one or more application versions that you want to delete.

1. Choose **Actions**, then choose **Delete**.

1. (Optional) To leave the application source bundle for these application versions in your Amazon Simple Storage Service (Amazon S3) bucket, clear the box for **Delete versions from Amazon S3**.

1. Choose **Delete**.

If you don't choose to delete the source bundle from Amazon S3, Elastic Beanstalk still deletes the version from its records. However, the source bundle is left in your [Elastic Beanstalk storage bucket](AWSHowTo.S3.md). The application version quota applies only to versions Elastic Beanstalk tracks. Therefore, you can delete versions to stay within the quota, but retain all source bundles in Amazon S3.

**Note**  
The application version quota doesn't apply to source bundles, but you might still incur Amazon S3 charges, and retain personal information beyond the time you need it. Elastic Beanstalk never deletes source bundles automatically. You should delete source bundles when you no longer need them.

# Configuring application version lifecycle settings
<a name="applications-lifecycle"></a>

This topic explains the policies and quotas that Elastic Beanstalk applies to the versions of your application in a given environment, including how long an application version remains in an environment.

Each time you upload a new version of your application with the Elastic Beanstalk console or the EB CLI, Elastic Beanstalk creates an [application version](applications-versions.md). If you don't delete versions that you no longer use, you will eventually reach the [application version quota](https://docs.aws.amazon.com/general/latest/gr/elasticbeanstalk.html#limits_elastic_beanstalk) and be unable to create new versions of that application.

You can avoid hitting the quota by applying an *application version lifecycle policy* to your applications. A lifecycle policy tells Elastic Beanstalk to delete application versions that are old, or to delete application versions when the total number of versions for an application exceeds a specified number.

Elastic Beanstalk applies an application's lifecycle policy each time you create a new application version, and deletes up to 100 versions each time the lifecycle policy is applied. Elastic Beanstalk deletes old versions after creating the new version, and does not count the new version towards the maximum number of versions defined in the policy.

Elastic Beanstalk does not delete application versions that are currently being used by an environment, or application versions deployed to environments that were terminated less than ten weeks before the policy was triggered.

The application version quota applies across all applications in a region. If you have several applications, configure each application with a lifecycle policy appropriate to avoid reaching the quota. For example, if you have 10 applications in a region and the quota is 1,000 application versions, consider setting a lifecycle policy with a quota of 99 application versions for all applications, or set other values in each application as long as the total is less than 1,000 application versions. Elastic Beanstalk only applies the policy if the application version creation succeeds, so if you have already reached the quota, you must delete some versions manually prior to creating a new version.

By default, Elastic Beanstalk leaves the application version's [source bundle](applications-sourcebundle.md) in Amazon S3 to prevent loss of data. You can delete the source bundle to save space.

You can set the lifecycle settings through the Elastic Beanstalk CLI and APIs. See [**eb appversion**](eb3-appversion.md), [CreateApplication](https://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplication.html) (using the `ResourceLifecycleConfig` parameter), and [UpdateApplicationResourceLifecycle](https://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_UpdateApplicationResourceLifecycle.html) for details.

## Setting the application lifecycle settings in the console
<a name="applications-lifecycle-console"></a>

You can specify the lifecycle settings in the Elastic Beanstalk console.

**To specify your application lifecycle settings**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

1. In the navigation pane, find your application's name and choose **Application versions**.

1. Choose **Settings**.

1. Use the on-screen form to configure application lifecycle settings.

1. Choose **Save**.

On the settings page, you can do the following.
+ Configure lifecycle settings based on the total count of application versions or the age of application versions.
+ Specify whether to delete the source bundle from S3 when the application version is deleted.
+ Specify the service role under which the application version is deleted. To include all permissions required for version deletion, choose the default Elastic Beanstalk service role, named `aws-elasticbeanstalk-service-role`, or another service role using the Elastic Beanstalk managed service policies. For more information, see [Managing Elastic Beanstalk service roles](iam-servicerole.md).

# Tagging application versions
<a name="applications-versions-tagging"></a>

This topic explains the benefits of tagging your Elastic Beanstalk application versions and how to manage the tags.

You can apply tags to your AWS Elastic Beanstalk application versions. Tags are key-value pairs associated with AWS resources. For information about Elastic Beanstalk resource tagging, use cases, tag key and value constraints, and supported resource types, see [Tagging Elastic Beanstalk application resources](applications-tagging-resources.md).

You can specify tags when you create an application version. In an existing application version, you can add or remove tags, and update the values of existing tags. You can add up to 50 tags to each application version.

## Adding tags during application version creation
<a name="applications-versions-tagging.create"></a>

When you use the Elastic Beanstalk console to [create an environment](environments-create-wizard.md), and you choose to upload a version of your application code, you can specify tag keys and values to associate with the new application version.

You can also use the Elastic Beanstalk console to [upload an application version](applications-versions.md) without immediately using it in an environment. You can specify tag keys and values when you upload an application version.

With the AWS CLI or other API-based clients, add tags by using the `--tags` parameter on the **[create-application-version](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/create-application-version.html)** command.

```
$ aws elasticbeanstalk create-application-version \
      --tags Key=mytag1,Value=value1 Key=mytag2,Value=value2 \
      --application-name my-app --version-label v1
```

When you use the EB CLI to create or update an environment, an application version is created from the code that you deploy. There isn't a direct way to tag an application version during its creation through the EB CLI. See the following section to learn about adding tags to an existing application version.

## Managing tags of an existing application version
<a name="applications-versions-tagging.manage"></a>

You can add, update, and delete tags in an existing Elastic Beanstalk application version.

**To manage an application version's tags using the Elastic Beanstalk console**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

1. In the navigation pane, find your application's name and choose **Application versions**.

1. Select the application version you want to manage.

1. Choose **Actions**, and then choose **Manage tags**.

1. Use the on-screen form to add, update, or delete tags.

1. To save the changes choose **Apply** at the bottom of the page.

If you use the EB CLI to update your application version, use **[eb tags](eb3-tags.md)** to add, update, delete, or list tags.

For example, the following command lists the tags in an application version.

```
~/workspace/my-app$ eb tags --list --resource "arn:aws:elasticbeanstalk:us-east-2:my-account-id:applicationversion/my-app/my-version"
```

The following command updates the tag `mytag1` and deletes the tag `mytag2`.

```
~/workspace/my-app$ eb tags --update mytag1=newvalue --delete mytag2 \
      --resource "arn:aws:elasticbeanstalk:us-east-2:my-account-id:applicationversion/my-app/my-version"
```

For a complete list of options and more examples, see `eb tags`.

With the AWS CLI or other API-based clients, use the **[list-tags-for-resource](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/list-tags-for-resource.html)** command to list the tags of an application version.

```
$ aws elasticbeanstalk list-tags-for-resource --resource-arn "arn:aws:elasticbeanstalk:us-east-2:my-account-id:applicationversion/my-app/my-version"
```

Use the **[update-tags-for-resource](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/update-tags-for-resource.html)** command to add, update, or delete tags in an application version.

```
$ aws elasticbeanstalk update-tags-for-resource \
      --tags-to-add Key=mytag1,Value=newvalue --tags-to-remove mytag2 \
      --resource-arn "arn:aws:elasticbeanstalk:us-east-2:my-account-id:applicationversion/my-app/my-version"
```

Specify both tags to add and tags to update in the `--tags-to-add` parameter of **update-tags-for-resource**. A nonexisting tag is added, and an existing tag's value is updated.

**Note**  
To use some of the EB CLI and AWS CLI commands with an Elastic Beanstalk application version, you need the application version's ARN. You can retrieve the ARN by using the following command.  

```
$ aws elasticbeanstalk describe-application-versions --application-name my-app --version-label my-version
```

# Create an Elastic Beanstalk application source bundle
<a name="applications-sourcebundle"></a>

This topic explains how to upload your application source files to Elastic Beanstalk in a source bundle. It explains the requirements of a source bundle, the structure, and the approaches to create one.

When you use the AWS Elastic Beanstalk console to deploy a new application or an application version, you'll need to upload the files for the application in a *source bundle*. Your source bundle must meet the following requirements: 
+ Consist of a single `ZIP` file or `WAR` file (you can include multiple `WAR` files inside your `ZIP` file)
+ Not exceed 500 MB
+ Not include a parent folder or top-level directory (subdirectories are fine)

If you want to deploy a worker application that processes periodic background tasks, your application source bundle must also include a `cron.yaml` file. For more information, see [Periodic tasks](using-features-managing-env-tiers.md#worker-periodictasks).

If you are deploying your application with the Elastic Beanstalk Command Line Interface (EB CLI), the AWS Toolkit for Eclipse, or the AWS Toolkit for Visual Studio, the ZIP or WAR file will automatically be structured correctly. For more information, see [Setting up the EB command line interface (EB CLI) to manage Elastic Beanstalk](eb-cli3.md), [Deploying Java applications with Elastic Beanstalk](create_deploy_Java.md), and [The AWS Toolkit for Visual Studio](dotnet-toolkit.md).

**Topics**
+ [Creating a source bundle from the command line](#using-features.deployment.source.commandline)
+ [Creating a source bundle with Git](#using-features.deployment.source.git)
+ [Zipping files in Mac OS X Finder or Windows explorer](#using-features.deployment.source.gui)
+ [Creating a source bundle for a .NET application](#using-features.deployment.source.dotnet)
+ [Testing your source bundle](#using-features.deployment.source.test)

## Creating a source bundle from the command line
<a name="using-features.deployment.source.commandline"></a>

Create a source bundle using the `zip` command. To include hidden files and folders, use a pattern like the following.

```
~/myapp$ zip ../myapp.zip -r * .[^.]*
  adding: app.js (deflated 63%)
  adding: index.js (deflated 44%)
  adding: manual.js (deflated 64%)
  adding: package.json (deflated 40%)
  adding: restify.js (deflated 85%)
  adding: .ebextensions/ (stored 0%)
  adding: .ebextensions/xray.config (stored 0%)
```

This ensures that Elastic Beanstalk [configuration files](ebextensions.md) and other files and folders that start with a period are included in the archive.

For Tomcat web applications, use `jar` to create a web archive.

```
~/myapp$ jar -cvf myapp.war .
```

The above commands include hidden files that may increase your source bundle size unnecessarily. For more control, use a more detailed file pattern, or [create your source bundle with Git](#using-features.deployment.source.git).

## Creating a source bundle with Git
<a name="using-features.deployment.source.git"></a>

If you're using Git to manage your application source code, use the `git archive` command to create your source bundle.

```
$ git archive -v -o myapp.zip --format=zip HEAD
```

`git archive` only includes files that are stored in git, and excludes ignored files and git files. This helps keep your source bundle as small as possible. For more information, go to the [git-archive manual page](http://git-scm.com/docs/git-archive).

## Zipping files in Mac OS X Finder or Windows explorer
<a name="using-features.deployment.source.gui"></a>

When you create a `ZIP` file in Mac OS X Finder or Windows Explorer, make sure you zip the files and subfolders themselves, rather than zipping the parent folder. 

**Note**  
The graphical user interface (GUI) on Mac OS X and Linux-based operating systems does not display files and folders with names that begin with a period (.). Use the command line instead of the GUI to compress your application if the `ZIP` file must include a hidden folder, such as `.ebextensions`. For command line procedures to create a `ZIP` file on Mac OS X or a Linux-based operating system, see [Creating a source bundle from the command line](#using-features.deployment.source.commandline).

**Example**  
Suppose you have a Python project folder labeled `myapp`, which includes the following files and subfolders:   

```
myapplication.py
README.md
static/
static/css
static/css/styles.css
static/img
static/img/favicon.ico
static/img/logo.png
templates/
templates/base.html
templates/index.html
```
As noted in the list of requirements above, your source bundle must be compressed without a parent folder, so that its decompressed structure does not include an extra top-level directory. In this example, no `myapp` folder should be created when the files are decompressed (or, at the command line, no `myapp` segment should be added to the file paths).   
This sample file structure is used throughout this topic to illustrate how to zip files.

## Creating a source bundle for a .NET application
<a name="using-features.deployment.source.dotnet"></a>

If you use Visual Studio, you can use the deployment tool included in the AWS Toolkit for Visual Studio to deploy your .NET application to Elastic Beanstalk. For more information, see [Deploying Elastic Beanstalk applications in .NET using AWS deployment tools](deploy_NET_standalone_tool.md).

If you need to manually create a source bundle for your .NET application, you cannot simply create a `ZIP` file that contains the project directory. You must create a web deployment package for your project that is suitable for deployment to Elastic Beanstalk. There are several methods you can use to create a deployment package:
+ Create the deployment package using the **Publish Web** wizard in Visual Studio. For more information, go to [How to: Create a Web Deployment Package in Visual Studio](http://msdn.microsoft.com/en-us/library/dd465323.aspx).
**Important**  
When creating the web deployment package, you must start the **Site name** with `Default Web Site`.
+ If you have a .NET project, you can create the deployment package using the **msbuild** command as shown in the following example. 
**Important**  
The `DeployIisAppPath` parameter must begin with `Default Web Site`.

  ```
  C:/> msbuild <web_app>.csproj /t:Package /p:DeployIisAppPath="Default Web Site"
  ```
+ If you have a website project, you can use the IIS Web Deploy tool to create the deployment package. For more information, go to [Packaging and Restoring a Web site](http://www.iis.net/learn/publish/using-web-deploy/packaging-and-restoring-a-web-site).
**Important**  
The `apphostconfig` parameter must begin with `Default Web Site`.

If you are deploying multiple applications or an ASP.NET Core application, put your `.ebextensions` folder in the root of the source bundle, side by side with the application bundles and manifest file:

```
~/workspace/source-bundle/
|-- .ebextensions
|   |-- environmentvariables.config
|   `-- healthcheckurl.config
|-- AspNetCore101HelloWorld.zip
|-- AspNetCoreHelloWorld.zip
|-- aws-windows-deployment-manifest.json
`-- VS2015AspNetWebApiApp.zip
```

## Testing your source bundle
<a name="using-features.deployment.source.test"></a>

You may want to test your source bundle locally before you upload it to Elastic Beanstalk. Because Elastic Beanstalk essentially uses the command line to extract the files, it's best to do your tests from the command line rather than with a GUI tool. 

Ensure that the decompressed files appear in the same folder as the archive itself, rather than in a new top-level folder or directory.

# Using the EB CLI with AWS CodeBuild
<a name="eb-cli-codebuild"></a>

[AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/) compiles your source code, runs unit tests, and produces artifacts that are ready to deploy. You can use CodeBuild together with the EB CLI to automate building your application from its source code. Environment creation and each deployment thereafter start with a build step, and then deploy the resulting application.

**Note**  
Some regions don't offer CodeBuild. The integration between Elastic Beanstalk and CodeBuild doesn't work in these regions.  
For information about the AWS services offered in each region, see [Region Table](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/).

## Creating an application
<a name="eb-cli-codebuild-using"></a>

**To create an Elastic Beanstalk application that uses CodeBuild**

1. Include a CodeBuild build specification file, [https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html), in your application folder.

1. Add an `eb_codebuild_settings` entry with options specific to Elastic Beanstalk to the file.

1. Run [**eb init**](eb3-init.md) in the folder.
**Note**  
Do not use the period (`.`) or space (` `) characters in *Application name* when you use the EB CLI with CodeBuild. 

Elastic Beanstalk extends the [CodeBuild build specification file format](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) to include the following additional settings:

```
eb_codebuild_settings:
  CodeBuildServiceRole: role-name
  ComputeType: size
  Image: image
  Timeout: minutes
```

`CodeBuildServiceRole`  
The ARN or name of the AWS Identity and Access Management (IAM) service role that CodeBuild can use to interact with dependent AWS services on your behalf. This value is required. If you omit it, any subsequent **eb create** or **eb deploy** command fails.  
To learn more about creating a service role for CodeBuild, see [Create a CodeBuild Service Role](https://docs.aws.amazon.com/codebuild/latest/userguide/setting-up.html#setting-up-service-role) in the *AWS CodeBuild User Guide*.  
You also need permissions to perform actions in CodeBuild itself. The Elastic Beanstalk **AdministratorAccess-AWSElasticBeanstalk** managed user policy includes all the required CodeBuild action permissions. If you're not using the managed policy, be sure to allow the following permissions in your user policy.  

```
  "codebuild:CreateProject",
  "codebuild:DeleteProject",
  "codebuild:BatchGetBuilds",
  "codebuild:StartBuild"
```
For details, see [Managing Elastic Beanstalk user policies](AWSHowTo.iam.managed-policies.md).

`ComputeType`  
The amount of resources used by the Docker container in the CodeBuild build environment. Valid values are BUILD\$1GENERAL1\$1SMALL, BUILD\$1GENERAL1\$1MEDIUM, and BUILD\$1GENERAL1\$1LARGE.

`Image`  
The name of the Docker Hub or Amazon ECR image that CodeBuild uses for the build environment. This Docker image should contain all the tools and runtime libraries required to build your code, and should match your application's target platform. CodeBuild manages and maintains a set of images specifically meant to be used with Elastic Beanstalk. It is recommended that you use one of them. For details, see [Docker Images Provided by CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html) in the *AWS CodeBuild User Guide*.  
The `Image` value is optional. If you omit it, the **eb init** command attempts to choose an image that best matches your target platform. In addition, if you run **eb init** in interactive mode and it fails to choose an image for you, it prompts you to choose one. At the end of a successful initialization, **eb init** writes the chosen image into the `buildspec.yml` file.

`Timeout`  
The duration, in minutes, that the CodeBuild build runs before timing out. This value is optional. For details about valid and default values, see [Create a Build Project in CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/create-project.html).  
This timeout controls the maximum duration for a CodeBuild run, and the EB CLI also respects it as part of its first step to create an application version. It's distinct from the value you can specify with the `--timeout` option of the [**eb create**](eb3-create.md) or [**eb deploy**](eb3-deploy.md) commands. The latter value controls the maximum duration that for EB CLI to wait for environment creation or update.

## Building and deploying your application code
<a name="eb-cli-codebuild-using"></a>

Whenever your application code needs to be deployed, the EB CLI uses CodeBuild to run a build, then deploys the resulting build artifacts to your environment. This happens when you create an Elastic Beanstalk environment for your application using the [**eb create**](eb3-create.md) command, and each time you later deploy code changes to the environment using the [**eb deploy**](eb3-deploy.md) command.

If the CodeBuild step fails, environment creation or deployment doesn't start.

# Tagging applications
<a name="applications-tagging"></a>

This topic explains the benefits of tagging your Elastic Beanstalk applications. It also provides instructions to create and manage application tags. Tags are key-value pairs associated with AWS resources. For information about Elastic Beanstalk resource tagging, use cases, tag key and value constraints, and supported resource types, see [Tagging Elastic Beanstalk application resources](applications-tagging-resources.md).

You can specify tags when you create an application. In an existing application, you can add or remove tags, and update the values of existing tags. You can add up to 50 tags to each application.

## Adding tags during application creation
<a name="applications-tagging.create"></a>

When you use the Elastic Beanstalk console to [create an application](applications.md), you can specify tag keys and values in the **Create New Application** dialog box.

If you use the EB CLI to create an application, use the `--tags` option with **[eb init](eb3-init.md)** to add tags.

```
~/workspace/my-app$ eb init --tags mytag1=value1,mytag2=value2
```

With the AWS CLI or other API-based clients, add tags by using the `--tags` parameter on the **[create-application](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/create-application.html)** command.

```
$ aws elasticbeanstalk create-application \
      --tags Key=mytag1,Value=value1 Key=mytag2,Value=value2 \
      --application-name my-app --version-label v1
```

## Managing tags of an existing application
<a name="applications-tagging.manage"></a>

You can add, update, and delete tags in an existing Elastic Beanstalk application.

**To manage an application's tags in the Elastic Beanstalk console**

1. Open the [Elastic Beanstalk console](https://console.aws.amazon.com/elasticbeanstalk), and in the **Regions** list, select your AWS Region.

1. In the navigation pane, choose **Applications**, and then choose your application's name from the list.

1. Choose **Actions**, and then choose **Manage tags**.

1. Use the on-screen form to add, update, or delete tags.

1. To save the changes choose **Apply** at the bottom of the page.

If you use the EB CLI to update your application, use **[eb tags](eb3-tags.md)** to add, update, delete, or list tags.

For example, the following command lists the tags in an application.

```
~/workspace/my-app$ eb tags --list --resource "arn:aws:elasticbeanstalk:us-east-2:my-account-id:application/my-app"
```

The following command updates the tag `mytag1` and deletes the tag `mytag2`.

```
~/workspace/my-app$ eb tags --update mytag1=newvalue --delete mytag2 \
      --resource "arn:aws:elasticbeanstalk:us-east-2:my-account-id:application/my-app"
```

For a complete list of options and more examples, see `eb tags`.

With the AWS CLI or other API-based clients, use the **[list-tags-for-resource](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/list-tags-for-resource.html)** command to list the tags of an application.

```
$ aws elasticbeanstalk list-tags-for-resource --resource-arn "arn:aws:elasticbeanstalk:us-east-2:my-account-id:application/my-app"
```

Use the **[update-tags-for-resource](https://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/update-tags-for-resource.html)** command to add, update, or delete tags in an application.

```
$ aws elasticbeanstalk update-tags-for-resource \
      --tags-to-add Key=mytag1,Value=newvalue --tags-to-remove mytag2 \
      --resource-arn "arn:aws:elasticbeanstalk:us-east-2:my-account-id:application/my-app"
```

Specify both tags to add and tags to update in the `--tags-to-add` parameter of **update-tags-for-resource**. A nonexisting tag is added, and an existing tag's value is updated.

**Note**  
To use some of the EB CLI and AWS CLI commands with an Elastic Beanstalk application, you need the application's ARN. You can retrieve the ARN by using the following command.  

```
$ aws elasticbeanstalk describe-applications --application-names my-app
```

# Tagging Elastic Beanstalk application resources
<a name="applications-tagging-resources"></a>

This topic explains the benefits of using tags with your Elastic Beanstalk application resources along with the constraints of doing so. It also explains how to create and manage tags for application resources.

You can apply tags to resources of your AWS Elastic Beanstalk applications. Tags are key-value pairs associated with AWS resources. Tags can help you categorize resources. They're particularly useful if you manage many resources as part of multiple AWS applications.

Here are some ways to use tagging with Elastic Beanstalk resources:
+ *Deployment stages* – Identify resources associated with different stages of your application, such as development, beta, and production.
+ *Cost allocation* – Use cost allocation reports to track your usage of AWS resources associated with various expense accounts. The reports include both tagged and untagged resources, and they aggregate costs according to tags. For information about how cost allocation reports use tags, see [Use Cost Allocation Tags for Custom Billing Reports](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/allocation.html) in the *AWS Billing and Cost Management User Guide*.
+ *Access control* – Use tags to manage permissions to requests and resources. For example, a user who can only create and manage beta environments should only have access to beta stage resources. For details, see [Using tags to control access to Elastic Beanstalk resourcesExamples of tag conditions in policies](AWSHowTo.iam.policies.access-tags.md).

You can add up to 50 tags to each resource. Environments are slightly different: Elastic Beanstalk adds three default system tags to environments, and you can't edit or delete these tags. In addition to the default tags, you can add up to 47 additional tags to each environment.

The following constraints apply to tag keys and values:
+ Keys and values can contain letters, numbers, white space, and the following symbols: `_ . : / = + - @`
+ Keys can contain up to 127 characters. Values can contain up to 255 characters.
**Note**  
These length limits are for Unicode characters in UTF-8. For other multibyte encodings, the limits might be lower.
+ Keys are case sensitive.
+ Keys cannot begin with `aws:` or `elasticbeanstalk:`.

## Resources you can tag
<a name="applications-tagging-resources.supported"></a>

The following are the types of Elastic Beanstalk resources that you can tag, and links to specific topics about managing tags for each of them:
+ [Applications](applications-tagging.md)
+ [Environments](using-features.tagging.md)
+ [Application versions](applications-versions-tagging.md)
+ [Saved configurations](environment-configuration-savedconfig-tagging.md)

# Tag propagation to launch templates
<a name="applications-tagging-resources.launch-templates"></a>

Elastic Beanstalk provides an option to enable the propagation of environment tags to launch templates. This option provides continued support for tag-based access control (TBAC) with launch templates.

**Note**  
Launch configurations are being phased out and replaced by launch templates. For more information, see [Launch configurations](https://docs.aws.amazon.com/autoscaling/ec2/userguide/launch-configurations.html) in the *Amazon EC2 Auto Scaling User Guide*.

To prevent down-time of running EC2 instances CloudFormation doesn’t propagate tags to existing launch templates. If there's a use case that requires tags for your environment’s resources, you can enable Elastic Beanstalk to create launch templates with tags for these resources. To do so, set the `LaunchTemplateTagPropagationEnabled` option in the [aws:autoscaling:launchconfiguration](command-options-general.md#command-options-general-autoscalinglaunchconfiguration) namespace to `true`. The default value is `false`.

The following [configuration file](ebextensions.md) example enables the propagation of tags to launch templates.

```
option_settings:
  aws:autoscaling:launchconfiguration:
    LaunchTemplateTagPropagationEnabled: true
```

Elastic Beanstalk can only propagate tags to launch templates for the following resources:
+ EBS volumes
+ EC2 instances 
+ EC2 network interfaces
+ CloudFormation launch templates that define a resource

This constraint exists because CloudFormation only allows tags on template creation for specific resources. For more information see [TagSpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-tagspecification.html) in the *AWS CloudFormation User Guide*.

**Important**  
Changing this option value from `false` to `true` for an existing environment may be a breaking change for previously existing tags.
When this feature is enabled, the propagation of tags will require EC2 replacement, which can result in downtime. You can enable *rolling updates* to apply configuration changes in batches and prevent downtime during the update process. For more information, see [Configuration changes](environments-updating.md).

For more information about launch templates, see the following:
+ [Launch templates](https://docs.aws.amazon.com/autoscaling/ec2/userguide/launch-templates.html) in the *Amazon EC2 Auto Scaling User Guide*
+ [Working with templates](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-guide.html) in the *AWS CloudFormation User Guide*
+ [Elastic Beanstalk template snippets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-elasticbeanstalk.html) in the *AWS CloudFormation User Guide*