

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# Création d'environnements pour votre application dans AWS AppConfig
<a name="appconfig-creating-environment"></a>

Pour chaque AWS AppConfig application, vous définissez un ou plusieurs environnements. Un environnement est un groupe de déploiement logique de AppConfig cibles, telles que des applications dans un `Beta` `Production` environnement, des AWS Lambda fonctions ou des conteneurs. Vous pouvez également définir des environnements pour les sous-composants de l'application, tels que `Web``Mobile`, et`Back-end`. Vous pouvez configurer les CloudWatch alarmes Amazon pour chaque environnement. Le système surveille les alarmes lors d'un déploiement de configuration. Si une alarme est déclenchée, le système annule la configuration. 

**Avant de commencer**  
Si vous AWS AppConfig souhaitez activer l'annulation d'une configuration en réponse à une CloudWatch alarme, vous devez configurer un rôle Gestion des identités et des accès AWS (IAM) avec des autorisations permettant de répondre AWS AppConfig aux CloudWatch alarmes. Vous choisissez ce rôle dans la procédure suivante. Pour de plus amples informations, veuillez consulter [Configurer les autorisations pour l'annulation automatique](setting-up-appconfig.md#getting-started-with-appconfig-cloudwatch-alarms-permissions).

**Topics**
+ [Création d'un AWS AppConfig environnement (console)](#appconfig-creating-environment-console)
+ [Création d'un AWS AppConfig environnement (ligne de commande)](#appconfig-creating-environment-commandline)

## Création d'un AWS AppConfig environnement (console)
<a name="appconfig-creating-environment-console"></a>

Pour créer un AWS AppConfig environnement à l'aide de la AWS Systems Manager console, procédez comme suit.

**Pour créer un environnement**

1. Ouvrez la AWS Systems Manager console à l'adresse [https://console.aws.amazon.com/systems-manager/appconfig/](https://console.aws.amazon.com/systems-manager/appconfig/).

1. Dans le volet de navigation, choisissez **Applications**, puis le nom d'une application pour ouvrir la page de détails.

1. Choisissez l'onglet **Environnements**, puis sélectionnez **Créer un environnement**.

1. Pour **Name (Nom)**, entrez un nom pour l'environnement.

1. Pour **Description**, entrez les informations concernant l'environnement.

1. (Facultatif) Dans la section **Moniteurs**, choisissez le champ **Rôle IAM**, puis choisissez un rôle IAM autorisé à faire appel `cloudwatch:DescribeAlarms` aux métriques que vous souhaitez surveiller pour détecter les alarmes.

1. Dans la liste des **CloudWatch alarmes**, entrez dans les Amazon Resource Names (ARN) une ou plusieurs métriques à surveiller. AWS AppConfig annule le déploiement de votre configuration si l'une de ces métriques passe à un `ALARM` état. Pour plus d'informations sur les mesures recommandées, voir [Surveillance des déploiements pour une annulation automatique](monitoring-deployments.md)

1. (Facultatif) Dans la section **Associer des extensions**, choisissez une extension dans la liste. Pour de plus amples informations, veuillez consulter [Comprendre les AWS AppConfig extensions](working-with-appconfig-extensions-about.md).

1. (Facultatif) Dans la section **Balises**, entrez une clé et une valeur facultative. Vous pouvez spécifier un maximum de 50 balises par ressource. 

1. Choisissez **Create environment**.

AWS AppConfig crée l'environnement, puis affiche la page des **détails de l'environnement**. Passez à [Création d'un profil de configuration dans AWS AppConfig](appconfig-creating-configuration-profile.md).

## Création d'un AWS AppConfig environnement (ligne de commande)
<a name="appconfig-creating-environment-commandline"></a>

La procédure suivante décrit comment utiliser AWS CLI (sous Linux ou Windows) ou comment Outils AWS pour PowerShell créer un AWS AppConfig environnement.

**Pour créer un environnement étape par étape**

1. Ouvrez le AWS CLI.

1. Exécutez la commande suivante pour créer un environnement. 

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

   ```
   aws appconfig create-environment \
     --application-id {{The_application_ID}} \
     --name {{A_name_for_the_environment}} \
     --description {{A_description_of_the_environment}} \
     --monitors "AlarmArn={{ARN_of_the_Amazon_CloudWatch_alarm}},AlarmArnRole={{ARN_of_the_IAM role_for_AWS AppConfig_to_monitor_AlarmArn}}" \
     --tags {{User_defined_key_value_pair_metadata_of_the_environment}}
   ```

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

   ```
   aws appconfig create-environment ^
     --application-id {{The_application_ID}} ^
     --name {{A_name_for_the_environment}} ^
     --description {{A_description_of_the_environment}} ^
     --monitors "AlarmArn={{ARN_of_the_Amazon_CloudWatch_alarm}},AlarmArnRole={{ARN_of_the_IAM role_for_AWS AppConfig_to_monitor_AlarmArn}}" ^
     --tags {{User_defined_key_value_pair_metadata_of_the_environment}}
   ```

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

   ```
   New-APPCEnvironment `
     -Name {{Name_for_the_environment}} `
     -ApplicationId {{The_application_ID}}
     -Description {{Description_of_the_environment}} `
     -Monitors @{"AlarmArn={{ARN_of_the_Amazon_CloudWatch_alarm}},AlarmArnRole={{ARN_of_the_IAM role_for_AWS AppConfig_to_monitor_AlarmArn}}"} `
     -Tag {{Hashtable_type_user_defined_key_value_pair_metadata_of_the_environment}}
   ```

------

   Le système retourne des informations telles que les suivantes.

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

   ```
   {
      "ApplicationId": "The application ID",
      "Id": "The_environment ID",
      "Name": "Name of the environment",
      "State": "The state of the environment",
      "Description": "Description of the environment",
      
      "Monitors": [ 
         { 
            "AlarmArn": "ARN of the Amazon CloudWatch alarm",
            "AlarmRoleArn": "ARN of the IAM role for AppConfig to monitor AlarmArn"
         }
      ]  
   }
   ```

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

   ```
   {
      "ApplicationId": "The application ID",
      "Id": "The environment ID",
      "Name": "Name of the environment",
      "State": "The state of the environment"
      "Description": "Description of the environment",
      
      "Monitors": [ 
         { 
            "AlarmArn": "ARN of the Amazon CloudWatch alarm",
            "AlarmRoleArn": "ARN of the IAM role for AppConfig to monitor AlarmArn"
         }
      ] 
   }
   ```

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

   ```
   ApplicationId     : The application ID
   ContentLength     : Runtime of the command
   Description       : Description of the environment
   HttpStatusCode    : HTTP Status of the runtime
   Id                : The environment ID
   Monitors          : {ARN of the Amazon CloudWatch alarm, ARN of the IAM role for AppConfig to monitor AlarmArn}
   Name              : Name of the environment
   Response Metadata : Runtime Metadata
   State             : State of the environment
   ```

------

Passez à [Création d'un profil de configuration dans AWS AppConfig](appconfig-creating-configuration-profile.md).