

# Deploying feature flags and configuration data in AWS AppConfig
<a name="deploying-feature-flags"></a>

After you [create required artifacts](https://docs.aws.amazon.com/appconfig/latest/userguide/creating-feature-flags-and-configuration-data.html) for working with feature flags and freeform configuration data, you can create a new deployment. When you create a new deployment, you specify the following information:
+ An application ID
+ A configuration profile ID
+ A configuration version
+ An environment ID where you want to deploy the configuration data
+ A deployment strategy ID that defines how fast you want the changes to take effect
+ An AWS Key Management Service (AWS KMS) key ID to encrypt the data using a customer managed key.

When you call the [StartDeployment](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_StartDeployment.html) API action, AWS AppConfig performs the following tasks:

1. Retrieves the configuration data from the underlying data store by using the location URI in the configuration profile.

1. Verifies the configuration data is syntactically and semantically correct by using the validators you specified when you created your configuration profile.

1. Caches a copy of the data so it is ready to be retrieved by your application. This cached copy is called the *deployed data*.

You can mitigate situations where deploying configuration data causes errors in your application by using a combination of AWS AppConfig deployment strategies and automatic rollbacks based on Amazon CloudWatch alarms. A deployment strategy enables you to slowly release changes to all targets or specific segments over minutes or hours—either session-based or along your own target dimension by leveraging entity-based deployments. After you configure CloudWatch, if one or more alarms go into the alarm state during a deployment, AWS AppConfig automatically rolls back your configuration data to the previous version. For more information about deployment strategies, see [Working with deployment strategies](appconfig-creating-deployment-strategy.md). For more information about automatic rollbacks, see [Monitoring deployments for automatic rollback](monitoring-deployments.md).

**Note**  
AWS AppConfig Agent (version 2.0.136060 or later) supports deploying feature flag or free-form configuration data to specific segments or individual users during a gradual rollout. Entity-based gradual deployments ensure that once a user or segment receives a configuration version, they continue to receive that same version throughout the deployment period, regardless of which compute resource serves their requests. For more information, see [Using AWS AppConfig Agent for user- or entity-based gradual deployments](appconfig-agent-how-to-use.md#appconfig-entity-based-gradual-deployments).

**Topics**
+ [Working with deployment strategies](appconfig-creating-deployment-strategy.md)
+ [Deploying a configuration](appconfig-deploying.md)
+ [Deploying AWS AppConfig configurations using CodePipeline](appconfig-integration-codepipeline.md)
+ [Reverting a configuration](appconfig-deploying-reverting.md)

# Working with deployment strategies
<a name="appconfig-creating-deployment-strategy"></a>

A deployment strategy enables you to slowly release changes to all targets or specific segments over minutes or hours—either session based or along your own target dimension by leveraging entity-based deployments.

**Note**  
AWS AppConfig Agent (version 2.0.136060 or later) supports deploying feature flag or free-form configuration data to specific segments or individual users during a gradual rollout. Entity-based gradual deployments ensure that once a user or segment receives a configuration version, they continue to receive that same version throughout the deployment period, regardless of which compute resource serves their requests. For more information, see [Using AWS AppConfig Agent for user- or entity-based gradual deployments](appconfig-agent-how-to-use.md#appconfig-entity-based-gradual-deployments).

An AWS AppConfig deployment strategy defines the following important aspects of a configuration deployment.


****  

| Setting | Description | 
| --- | --- | 
| Elapsed time | Deployment progress | 
| --- | --- | 
|  Deployment type  | Deployment type defines how the configuration deploys or *rolls out*. AWS AppConfig supports **Linear** and **Exponential** deployment types. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html)  | 
|  Step percentage (growth factor)  |  This setting specifies the percentage of callers to target during each step of the deployment.  In the SDK and the [AWS AppConfig API Reference](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_CreateDeploymentStrategy.html), `step percentage` is called `growth factor`.   | 
|  Deployment time  |  This setting specifies an amount of time during which AWS AppConfig deploys to hosts. This is not a timeout value. It is a window of time during which the deployment is processed in intervals. | 
|  Bake time  |  This setting specifies the amount of time AWS AppConfig monitors for Amazon CloudWatch alarms after the configuration has been deployed to 100% of its targets, before considering the deployment to be complete. If an alarm is triggered during this time, AWS AppConfig rolls back the deployment. You must configure permissions for AWS AppConfig to roll back based on CloudWatch alarms. For more information, see [Configure permissions for automatic rollback](setting-up-appconfig.md#getting-started-with-appconfig-cloudwatch-alarms-permissions).  | 
|  0 hour  |  0%  | 
|  2 hour  |  20%  | 
|  4 hour  |  40%  | 
|  6 hour  |  60%  | 
|  8 hour  |  80%  | 
|  10 hour  |  100%  | 

You can choose a predefined strategy included with AWS AppConfig or create your own. 

**Note**  
AWS AppConfig Agent (version 2.0.136060 or later) supports deploying feature flag or free-form configuration data to specific segments or individual users during a gradual rollout. Entity-based gradual deployments ensure that once a user or segment receives a configuration version, they continue to receive that same version throughout the deployment period, regardless of which compute resource serves their requests. For more information, see [Using AWS AppConfig Agent for user- or entity-based gradual deployments](appconfig-agent-how-to-use.md#appconfig-entity-based-gradual-deployments).

**Topics**
+ [Using predefined deployment strategies](appconfig-creating-deployment-strategy-predefined.md)
+ [Create a deployment strategy](appconfig-creating-deployment-strategy-create.md)

# Using predefined deployment strategies
<a name="appconfig-creating-deployment-strategy-predefined"></a>

AWS AppConfig includes predefined deployment strategies to help you quickly deploy a configuration. Instead of creating your own strategies, you can choose one of the following when you deploy a configuration.


****  

| Deployment strategy | Description | 
| --- | --- | 
|  AppConfig.Linear20PercentEvery6Minutes  | **AWS recommended**: This strategy deploys the configuration to 20% of all targets every six minutes for a 30 minute deployment. The system monitors for Amazon CloudWatch alarms for 30 minutes. If no alarms are received in this time, the deployment is complete. If an alarm is triggered during this time, AWS AppConfig rolls back the deployment.We recommend using this strategy for production deployments because it aligns with AWS best practices and includes additional emphasis on deployment safety due to its long duration and bake time.  | 
|  AppConfig.Canary10Percent20Minutes  | **AWS recommended**: This strategy processes the deployment exponentially using a 10% growth factor over 20 minutes. The system monitors for CloudWatch alarms for 10 minutes. If no alarms are received in this time, the deployment is complete. If an alarm is triggered during this time, AWS AppConfig rolls back the deployment.We recommend using this strategy for production deployments because it aligns with AWS best practices for configuration deployments.  | 
|  AppConfig.AllAtOnce  | **Quick**: This strategy deploys the configuration to all targets immediately. The system monitors for CloudWatch alarms for 10 minutes. If no alarms are received in this time, the deployment is complete. If an alarm is triggered during this time, AWS AppConfig rolls back the deployment.   | 
|  AppConfig.Linear50PercentEvery30Seconds  | **Testing/demonstration**: This strategy deploys the configuration to half of all targets every 30 seconds for a one-minute deployment. The system monitors for Amazon CloudWatch alarms for 1 minute. If no alarms are received in this time, the deployment is complete. If an alarm is triggered during this time, AWS AppConfig rolls back the deployment.We recommend using this strategy only for testing or demonstration purposes because it has a short duration and bake time.  | 

# Create a deployment strategy
<a name="appconfig-creating-deployment-strategy-create"></a>

If you don't want to use one of the predefined deployment strategies, you can create your own. You can create a maximum of 20 deployment strategies. When you deploy a configuration, you can choose the deployment strategy that works best for the application and the environment.

## Creating an AWS AppConfig deployment strategy (console)
<a name="appconfig-creating-deployment-strategy-create-console"></a>

Use the following procedure to create an AWS AppConfig deployment strategy by using the AWS Systems Manager console.

**To create a deployment strategy**

1. Open the AWS Systems Manager console at [https://console.aws.amazon.com/systems-manager/appconfig/](https://console.aws.amazon.com/systems-manager/appconfig/).

1. In the navigation pane, choose **Deployment strategies**, and then choose **Create deployment strategy**.

1. For **Name**, enter a name for the deployment strategy.

1. For **Description**, enter information about the deployment strategy.

1. For **Deployment type**, choose a type.

1. For **Step percentage**, choose the percentage of callers to target during each step of the deployment. 

1. For **Deployment time**, enter the total duration for the deployment in minutes or hours. 

1. For **Bake time**, enter the total time, in minutes or hours, to monitor for Amazon CloudWatch alarms before proceeding to the next step of a deployment or before considering the deployment to be complete. 

1. In the **Tags** section, enter a key and an optional value. You can specify a maximum of 50 tags for a resource. 

1. Choose **Create deployment strategy**.

**Important**  
If you created a configuration profile for AWS CodePipeline, then you must create a pipeline in CodePipeline that specifies AWS AppConfig as the *deploy provider*. You don't need to perform [Deploying a configuration](appconfig-deploying.md). However, you must configure a client to receive application configuration updates as described in [Retrieving configuration data without AWS AppConfig Agent](about-data-plane.md). For information about creating a pipeline that specifies AWS AppConfig as the deploy provider, see [Tutorial: Create a Pipeline that Uses AWS AppConfig as a Deployment Provider](https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-AppConfig.html) in the *AWS CodePipeline User Guide*. 

Proceed to [Deploying a configuration](appconfig-deploying.md).

## Creating an AWS AppConfig deployment strategy (command line)
<a name="appconfig-creating-deployment-strategy-create-commandline"></a>

The following procedure describes how to use the AWS CLI (on Linux or Windows) or AWS Tools for PowerShell to create an AWS AppConfig deployment strategy.

**To create a deployment strategy step by step**

1. Open the AWS CLI.

1. Run the following command to create a deployment strategy. 

------
#### [ Linux ]

   ```
   aws appconfig create-deployment-strategy \
     --name A_name_for_the_deployment_strategy \
     --description A_description_of_the_deployment_strategy \
     --deployment-duration-in-minutes Total_amount_of_time_for_a_deployment_to_last \
     --final-bake-time-in-minutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete \
     --growth-factor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval \
     --growth-type The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time \
     --replicate-to To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document \
     --tags User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------
#### [ Windows ]

   ```
   aws appconfig create-deployment-strategy ^
     --name A_name_for_the_deployment_strategy ^
     --description A_description_of_the_deployment_strategy ^
     --deployment-duration-in-minutes Total_amount_of_time_for_a_deployment_to_last ^
     --final-bake-time-in-minutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete ^
     --growth-factor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval ^
     --growth-type The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time ^
     --name A_name_for_the_deployment_strategy ^
     --replicate-to To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document ^
     --tags User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------
#### [ PowerShell ]

   ```
   New-APPCDeploymentStrategy ` 
     --Name A_name_for_the_deployment_strategy ` 
     --Description A_description_of_the_deployment_strategy `
     --DeploymentDurationInMinutes Total_amount_of_time_for_a_deployment_to_last `
     --FinalBakeTimeInMinutes Amount_of_time_AWS AppConfig_monitors_for_alarms_before_considering_the_deployment_to_be_complete `
     --GrowthFactor The_percentage_of_targets_to_receive_a_deployed_configuration_during_each_interval `
     --GrowthType The_linear_or_exponential_algorithm_used_to_define_how_percentage_grows_over_time `
     --ReplicateTo To_save_the_deployment_strategy_to_a_Systems_Manager_(SSM)_document `
     --Tag Hashtable_type_User_defined_key_value_pair_metadata_of_the_deployment_strategy
   ```

------

   The system returns information like the following.

------
#### [ Linux ]

   ```
   {
      "Id": "Id of the deployment strategy",
      "Name": "Name of the deployment strategy",
      "Description": "Description of the deployment strategy",
      "DeploymentDurationInMinutes": "Total amount of time the deployment lasted",
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": "The percentage of targets that received a deployed configuration during each interval",  
      "FinalBakeTimeInMinutes": "The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete",
      "ReplicateTo": "The Systems Manager (SSM) document where the deployment strategy is saved"
   }
   ```

------
#### [ Windows ]

   ```
   {
      "Id": "Id of the deployment strategy",
      "Name": "Name of the deployment strategy",
      "Description": "Description of the deployment strategy",
      "DeploymentDurationInMinutes": "Total amount of time the deployment lasted",
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": "The percentage of targets that received a deployed configuration during each interval",  
      "FinalBakeTimeInMinutes": "The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete",
      "ReplicateTo": "The Systems Manager (SSM) document where the deployment strategy is saved"
   }
   ```

------
#### [ PowerShell ]

   ```
   ContentLength               : Runtime of the command
   DeploymentDurationInMinutes : Total amount of time the deployment lasted
   Description                 : Description of the deployment strategy
   FinalBakeTimeInMinutes      : The amount of time AWS AppConfig monitored for alarms before considering the deployment to be complete
   GrowthFactor                : The percentage of targets that received a deployed configuration during each interval
   GrowthType                  : The linear or exponential algorithm used to define how percentage grew over time
   HttpStatusCode              : HTTP Status of the runtime
   Id                          : The deployment strategy ID
   Name                        : Name of the deployment strategy
   ReplicateTo                 : The Systems Manager (SSM) document where the deployment strategy is saved
   ResponseMetadata            : Runtime Metadata
   ```

------

# Deploying a configuration
<a name="appconfig-deploying"></a>

After you [create required artifacts](https://docs.aws.amazon.com/appconfig/latest/userguide/creating-feature-flags-and-configuration-data.html) for working with feature flags and freeform configuration data, you can create a new deployment by using the AWS Management Console, the AWS CLI, or the SDK. Starting a deployment in AWS AppConfig calls the [StartDeployment](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_StartDeployment.html) API operation. This call includes the IDs of the AWS AppConfig application, the environment, the configuration profile, and (optionally) the configuration data version to deploy. The call also includes the ID of the deployment strategy to use, which determines how the configuration data is deployed.

If you deploy secrets stored in AWS Secrets Manager, Amazon Simple Storage Service (Amazon S3) objects encrypted with a customer managed key, or secure string parameters stored in AWS Systems Manager Parameter Store encrypted with a customer managed key, you must specify a value for the `KmsKeyIdentifier` parameter. If your configuration is not encrypted or is encrypted with an AWS managed key, specifying a value for the `KmsKeyIdentifier` parameter is not required.

**Note**  
The value you specify for `KmsKeyIdentifier` must be a customer managed key. This doesn't have to be the same key you used to encrypt your configuration.  
When you start a deployment with a `KmsKeyIdentifier`, the permission policy attached to your AWS Identity and Access Management (IAM) principal must allow the `kms:GenerateDataKey` operation.

AWS AppConfig monitors the distribution to all hosts and reports status. If a distribution fails, then AWS AppConfig rolls back the configuration.

**Note**  
You can only deploy one configuration at a time to an environment. However, you can deploy one configuration each to different environments at the same time.

## Deploy a configuration (console)
<a name="appconfig-deploying-console"></a>

Use the following procedure to deploy an AWS AppConfig configuration by using the AWS Systems Manager console.

**To deploy a configuration by using the console**

1. Open the AWS Systems Manager console at [https://console.aws.amazon.com/systems-manager/appconfig/](https://console.aws.amazon.com/systems-manager/appconfig/).

1. In the navigation pane, choose **Applications**, and then choose an application you created in [Creating a namespace for your application in AWS AppConfig](appconfig-creating-namespace.md).

1. On the **Environments** tab, fill the radio button for an environment, and then choose **View details**.

1. Choose **Start deployment**.

1. For **Configuration**, choose a configuration from the list.

1. Depending on the source of your configuration, use the version list to choose the version you want to deploy. 

1. For **Deployment strategy**, choose a strategy from the list.

1. (Optional) For **Deployment description**, enter a description. 

1. For **Additional encryption options**, choose a AWS Key Management Service key from the list.

1. (Optional) In the **Tags** section, choose **Add new tag ** and enter a key and an optional value. You can specify a maximum of 50 tags for a resource. 

1. Choose **Start deployment**.

## Deploy a configuration (commandline)
<a name="appconfig-deploying-commandline"></a>

The following procedure describes how to use the AWS CLI (on Linux or Windows) or AWS Tools for PowerShell to deploy an AWS AppConfig configuration.

**To deploy a configuration step by step**

1. Open the AWS CLI.

1. Run the following command to deploy a configuration. 

------
#### [ Linux ]

   ```
   aws appconfig start-deployment \
     --application-id The_application_ID \
     --environment-id The_environment_ID \
     --deployment-strategy-id The_deployment_strategy_ID \
     --configuration-profile-id The_configuration_profile_ID \
     --configuration-version The_configuration_version_to_deploy \
     --description A_description_of_the_deployment \
     --tags User_defined_key_value_pair_metadata_of_the_deployment
   ```

------
#### [ Windows ]

   ```
   aws appconfig start-deployment ^
     --application-id The_application_ID ^
     --environment-id The_environment_ID ^
     --deployment-strategy-id The_deployment_strategy_ID ^
     --configuration-profile-id The_configuration_profile_ID ^
     --configuration-version The_configuration_version_to_deploy ^
     --description A_description_of_the_deployment ^
     --tags User_defined_key_value_pair_metadata_of_the_deployment
   ```

------
#### [ PowerShell ]

   ```
   Start-APPCDeployment `
     -ApplicationId The_application_ID `
     -ConfigurationProfileId The_configuration_profile_ID `
     -ConfigurationVersion The_configuration_version_to_deploy `
     -DeploymentStrategyId The_deployment_strategy_ID `
     -Description A_description_of_the_deployment `
     -EnvironmentId The_environment_ID `
     -Tag Hashtable_type_user_defined_key_value_pair_metadata_of_the_deployment
   ```

------

   The system returns information like the following.

------
#### [ Linux ]

   ```
   {   
      "ApplicationId": "The ID of the application that was deployed",
      "EnvironmentId" : "The ID of the environment",
      "DeploymentStrategyId": "The ID of the deployment strategy that was deployed",
      "ConfigurationProfileId": "The ID of the configuration profile that was deployed",
      "DeploymentNumber": The sequence number of the deployment,
      "ConfigurationName": "The name of the configuration",
      "ConfigurationLocationUri": "Information about the source location of the configuration",
      "ConfigurationVersion": "The configuration version that was deployed",
      "Description": "The description of the deployment",
      "DeploymentDurationInMinutes": Total amount of time the deployment lasted,
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": The percentage of targets to receive a deployed configuration during each interval,
      "FinalBakeTimeInMinutes": Time AWS AppConfig monitored for alarms before considering the deployment to be complete,
      "State": "The state of the deployment",  
   
      "EventLog": [ 
         { 
            "Description": "A description of the deployment event",
            "EventType": "The type of deployment event",
            "OccurredAt": The date and time the event occurred,
            "TriggeredBy": "The entity that triggered the deployment event"
         }
      ],
   
      "PercentageComplete": The percentage of targets for which the deployment is available,
      "StartedAt": The time the deployment started,
      "CompletedAt": The time the deployment completed   
   }
   ```

------
#### [ Windows ]

   ```
   {
      "ApplicationId": "The ID of the application that was deployed",
      "EnvironmentId" : "The ID of the environment",
      "DeploymentStrategyId": "The ID of the deployment strategy that was deployed",
      "ConfigurationProfileId": "The ID of the configuration profile that was deployed",
      "DeploymentNumber": The sequence number of the deployment,
      "ConfigurationName": "The name of the configuration",
      "ConfigurationLocationUri": "Information about the source location of the configuration",
      "ConfigurationVersion": "The configuration version that was deployed",
      "Description": "The description of the deployment",
      "DeploymentDurationInMinutes": Total amount of time the deployment lasted,
      "GrowthType": "The linear or exponential algorithm used to define how percentage grew over time",
      "GrowthFactor": The percentage of targets to receive a deployed configuration during each interval,
      "FinalBakeTimeInMinutes": Time AWS AppConfig monitored for alarms before considering the deployment to be complete,
      "State": "The state of the deployment",  
   
      "EventLog": [ 
         { 
            "Description": "A description of the deployment event",
            "EventType": "The type of deployment event",
            "OccurredAt": The date and time the event occurred,
            "TriggeredBy": "The entity that triggered the deployment event"
         }
      ],
   
      "PercentageComplete": The percentage of targets for which the deployment is available,
      "StartedAt": The time the deployment started,
      "CompletedAt": The time the deployment completed 
   }
   ```

------
#### [ PowerShell ]

   ```
   ApplicationId               : The ID of the application that was deployed
   CompletedAt                 : The time the deployment completed
   ConfigurationLocationUri    : Information about the source location of the configuration
   ConfigurationName           : The name of the configuration
   ConfigurationProfileId      : The ID of the configuration profile that was deployed
   ConfigurationVersion        : The configuration version that was deployed
   ContentLength               : Runtime of the deployment 
   DeploymentDurationInMinutes : Total amount of time the deployment lasted
   DeploymentNumber            : The sequence number of the deployment
   DeploymentStrategyId        : The ID of the deployment strategy that was deployed
   Description                 : The description of the deployment
   EnvironmentId               : The ID of the environment that was deployed
   EventLog                    : {Description : A description of the deployment event, EventType : The type of deployment event, OccurredAt : The date and time the event occurred,
            TriggeredBy : The entity that triggered the deployment event}
   FinalBakeTimeInMinutes      : Time AWS AppConfig monitored for alarms before considering the deployment to be complete
   GrowthFactor                : The percentage of targets to receive a deployed configuration during each interval
   GrowthType                  : The linear or exponential algorithm used to define how percentage grew over time
   HttpStatusCode              : HTTP Status of the runtime
   PercentageComplete          : The percentage of targets for which the deployment is available
   ResponseMetadata            : Runtime Metadata
   StartedAt                   : The time the deployment started
   State                       : The state of the deployment
   ```

------

# Deploying AWS AppConfig configurations using CodePipeline
<a name="appconfig-integration-codepipeline"></a>

AWS AppConfig is an integrated deploy action for AWS CodePipeline (CodePipeline). CodePipeline is a fully managed continuous delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. CodePipeline automates the build, test, and deploy phases of your release process every time there is a code change, based on the release model you define. For more information, see [What is AWS CodePipeline?](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html)

The integration of AWS AppConfig with CodePipeline offers the following benefits:
+ Customers who use CodePipeline to manage orchestration now have a lightweight means of deploying configuration changes to their applications without having to deploy their entire code base.
+ Customers who want to use AWS AppConfig to manage configuration deployments but are limited because AWS AppConfig does not support their current code or configuration store, now have additional options. CodePipeline supports AWS CodeCommit, GitHub, and BitBucket (to name a few).

**Note**  
AWS AppConfig integration with CodePipeline is only supported in AWS Regions where CodePipeline is [available](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/).

## How integration works
<a name="appconfig-integration-codepipeline-how"></a>

You start by setting up and configuring CodePipeline. This includes adding your configuration to a CodePipeline-supported code store. Next, you set up your AWS AppConfig environment by performing the following tasks:
+ [Create a namespace and a configuration profile](https://docs.aws.amazon.com/appconfig/latest/userguide/creating-feature-flags-and-configuration-data.html)
+ [Choose a predefined deployment strategy or create your own](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html)

After you complete these tasks, you create a pipeline in CodePipeline that specifies AWS AppConfig as the *deploy provider*. You can then make a change to your configuration and upload it to your CodePipeline code store. Uploading the new configuration automatically starts a new deployment in CodePipeline. After the deployment completes, you can verify your changes. For information about creating a pipeline that specifies AWS AppConfig as the deploy provider, see [Tutorial: Create a Pipeline That Uses AWS AppConfig as a Deployment Provider](https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-AppConfig.html) in the *AWS CodePipeline User Guide*. 

# Reverting a configuration
<a name="appconfig-deploying-reverting"></a>

During a deployment, you can mitigate situations where malformed or incorrect configuration data causes errors in your application by using automatic rollbacks (if an alarm triggers during a deployment) or by reverting the configuration data to the previous version (if a deployment successfully completed).

For automatic rollbacks, you can use a combination of AWS AppConfig [deployment strategies](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html) and Amazon CloudWatch alarms. Once configured, if one or more CloudWatch alarms go into the `ALARM` state during a deployment, AWS AppConfig automatically rolls back your configuration data to the previous version, thereby preventing application outages or errors. To get started, see [Configure permissions for automatic rollback](setting-up-appconfig.md#getting-started-with-appconfig-cloudwatch-alarms-permissions).

**Note**  
You can also roll back a configuration by calling the [StopDeployment](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_StopDeployment.html) API operation while a deployment is still in progress.

For deployments that successfully complete, AWS AppConfig also supports reverting configuration data to a previous version by using the `AllowRevert` parameter with the [StopDeployment](https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_StopDeployment.html) API operation. For some customers, reverting to a previous configuration after a successful deployment guarantees the data will be the same as it was before the deployment. Reverting also ignores alarm monitors, which may prevent a roll forward from progressing during an application emergency.

**Important**  
If you call `StopDeployment` with the `AllowRevert` parameter enabled, AWS AppConfig will revert the deployment only if the deployment succeeded within the last 72 hours. After 72 hours, the deployment can no longer be reverted. You must create a new deployment.

Here's a breakdown of the `StopDeployment` functionality based on different situations.

1. If `StopDeployment` is called on an in-progress deployment, the resulting deployment state will be `ROLLED_BACK`.

1. If `StopDeployment` (with `AllowRevert`) is called on an in-progress deployment, the resulting deployment state will be `ROLLED_BACK`.

1. If `StopDeployment` is called on a completed deployment, a `BadRequestException` will be thrown.

1. If `StopDeployment` (with `AllowRevert`) is called on a completed deployment, the resulting deployment state will be `REVERTED`.

1. If `StopDeployment` (with `AllowRevert`) is called on a completed deployment after 72 hours, a `BadRequestException` will be thrown.

You can use the AWS CLI to call the [StopDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/appconfig/stop-deployment.html) operation with the `AllowRevert` parameter. Here's an example AWS CLI command that includes the `AllowRevert` parameter.

```
aws appconfig stop-deployment \
    --application-id 339ohji \
    --environment-id 54j1r29 \
    --deployment-number 2 \
    --allow-revert
```