:doc:`AppConfig <../../appconfig>` / Client / create_environment

******************
create_environment
******************



.. py:method:: AppConfig.Client.create_environment(**kwargs)

  

  Creates an environment. For each application, you define one or more environments. An environment is a deployment group of AppConfig targets, such as applications in a ``Beta`` or ``Production`` environment. You can also define environments for application subcomponents such as the ``Web``, ``Mobile`` and ``Back-end`` components for your application. You can configure Amazon CloudWatch alarms for each environment. The system monitors alarms during a configuration deployment. If an alarm is triggered, the system rolls back the configuration.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/appconfig-2019-10-09/CreateEnvironment>`_  


  **Request Syntax**
  ::

    response = client.create_environment(
        ApplicationId='string',
        Name='string',
        Description='string',
        Monitors=[
            {
                'AlarmArn': 'string',
                'AlarmRoleArn': 'string'
            },
        ],
        Tags={
            'string': 'string'
        }
    )
    
  :type ApplicationId: string
  :param ApplicationId: **[REQUIRED]** 

    The application ID.

    

  
  :type Name: string
  :param Name: **[REQUIRED]** 

    A name for the environment.

    

  
  :type Description: string
  :param Description: 

    A description of the environment.

    

  
  :type Monitors: list
  :param Monitors: 

    Amazon CloudWatch alarms to monitor during the deployment process.

    

  
    - *(dict) --* 

      Amazon CloudWatch alarms to monitor during the deployment process.

      

    
      - **AlarmArn** *(string) --* **[REQUIRED]** 

        Amazon Resource Name (ARN) of the Amazon CloudWatch alarm.

        

      
      - **AlarmRoleArn** *(string) --* 

        ARN of an Identity and Access Management (IAM) role for AppConfig to monitor ``AlarmArn``.

        

      
    

  :type Tags: dict
  :param Tags: 

    Metadata to assign to the environment. Tags help organize and categorize your AppConfig resources. Each tag consists of a key and an optional value, both of which you define.

    

  
    - *(string) --* 

    
      - *(string) --* 

      


  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'ApplicationId': 'string',
          'Id': 'string',
          'Name': 'string',
          'Description': 'string',
          'State': 'READY_FOR_DEPLOYMENT'|'DEPLOYING'|'ROLLING_BACK'|'ROLLED_BACK'|'REVERTED',
          'Monitors': [
              {
                  'AlarmArn': 'string',
                  'AlarmRoleArn': 'string'
              },
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **ApplicationId** *(string) --* 

        The application ID.

        
      

      - **Id** *(string) --* 

        The environment ID.

        
      

      - **Name** *(string) --* 

        The name of the environment.

        
      

      - **Description** *(string) --* 

        The description of the environment.

        
      

      - **State** *(string) --* 

        The state of the environment. An environment can be in one of the following states: ``READY_FOR_DEPLOYMENT``, ``DEPLOYING``, ``ROLLING_BACK``, or ``ROLLED_BACK``

        
      

      - **Monitors** *(list) --* 

        Amazon CloudWatch alarms monitored during the deployment.

        
        

        - *(dict) --* 

          Amazon CloudWatch alarms to monitor during the deployment process.

          
          

          - **AlarmArn** *(string) --* 

            Amazon Resource Name (ARN) of the Amazon CloudWatch alarm.

            
          

          - **AlarmRoleArn** *(string) --* 

            ARN of an Identity and Access Management (IAM) role for AppConfig to monitor ``AlarmArn``.

            
      
    
  
  **Exceptions**
  
  *   :py:class:`AppConfig.Client.exceptions.InternalServerException`

  
  *   :py:class:`AppConfig.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`AppConfig.Client.exceptions.BadRequestException`

  
  *   :py:class:`AppConfig.Client.exceptions.ServiceQuotaExceededException`

  

  **Examples**

  The following create-environment example creates an AWS AppConfig environment named Example-Environment using the application you created using create-application
  ::

    response = client.create_environment(
        ApplicationId='339ohji',
        Name='Example-Environment',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ApplicationId': '339ohji',
        'Id': '54j1r29',
        'Name': 'Example-Environment',
        'State': 'READY_FOR_DEPLOYMENT',
        'ResponseMetadata': {
            '...': '...',
        },
    }

  