:doc:`Lambda <../../lambda>` / Client / update_alias

************
update_alias
************



.. py:method:: Lambda.Client.update_alias(**kwargs)

  

  Updates the configuration of a Lambda function `alias <https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html>`__.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/lambda-2015-03-31/UpdateAlias>`_  


  **Request Syntax**
  ::

    response = client.update_alias(
        FunctionName='string',
        Name='string',
        FunctionVersion='string',
        Description='string',
        RoutingConfig={
            'AdditionalVersionWeights': {
                'string': 123.0
            }
        },
        RevisionId='string'
    )
    
  :type FunctionName: string
  :param FunctionName: **[REQUIRED]** 

    The name or ARN of the Lambda function.

     

    **Name formats**

     

    
    * **Function name** - ``MyFunction``.
     
    * **Function ARN** - ``arn:aws:lambda:us-west-2:123456789012:function:MyFunction``.
     
    * **Partial ARN** - ``123456789012:function:MyFunction``.
    

     

    The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

    

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

    The name of the alias.

    

  
  :type FunctionVersion: string
  :param FunctionVersion: 

    The function version that the alias invokes.

    

  
  :type Description: string
  :param Description: 

    A description of the alias.

    

  
  :type RoutingConfig: dict
  :param RoutingConfig: 

    The `routing configuration <https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html#configuring-alias-routing>`__ of the alias.

    

  
    - **AdditionalVersionWeights** *(dict) --* 

      The second version, and the percentage of traffic that's routed to it.

      

    
      - *(string) --* 

      
        - *(float) --* 

        
  

  
  :type RevisionId: string
  :param RevisionId: 

    Only update the alias if the revision ID matches the ID that's specified. Use this option to avoid modifying an alias that has changed since you last read it.

    

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

    
    ::

      {
          'AliasArn': 'string',
          'Name': 'string',
          'FunctionVersion': 'string',
          'Description': 'string',
          'RoutingConfig': {
              'AdditionalVersionWeights': {
                  'string': 123.0
              }
          },
          'RevisionId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Provides configuration information about a Lambda function `alias <https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html>`__.

      
      

      - **AliasArn** *(string) --* 

        The Amazon Resource Name (ARN) of the alias.

        
      

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

        The name of the alias.

        
      

      - **FunctionVersion** *(string) --* 

        The function version that the alias invokes.

        
      

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

        A description of the alias.

        
      

      - **RoutingConfig** *(dict) --* 

        The `routing configuration <https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html>`__ of the alias.

        
        

        - **AdditionalVersionWeights** *(dict) --* 

          The second version, and the percentage of traffic that's routed to it.

          
          

          - *(string) --* 
            

            - *(float) --* 
      
    
    
      

      - **RevisionId** *(string) --* 

        A unique identifier that changes when you update the alias.

        
  
  **Exceptions**
  
  *   :py:class:`Lambda.Client.exceptions.InvalidParameterValueException`

  
  *   :py:class:`Lambda.Client.exceptions.ResourceConflictException`

  
  *   :py:class:`Lambda.Client.exceptions.ServiceException`

  
  *   :py:class:`Lambda.Client.exceptions.TooManyRequestsException`

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

  
  *   :py:class:`Lambda.Client.exceptions.PreconditionFailedException`

  

  **Examples**

  The following example updates the alias named BLUE to send 30% of traffic to version 2 and 70% to version 1.
  ::

    response = client.update_alias(
        FunctionName='my-function',
        FunctionVersion='2',
        Name='BLUE',
        RoutingConfig={
            'AdditionalVersionWeights': {
                '1': 0.7,
            },
        },
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'AliasArn': 'arn:aws:lambda:us-west-2:123456789012:function:my-function:BLUE',
        'Description': 'Production environment BLUE.',
        'FunctionVersion': '2',
        'Name': 'BLUE',
        'RevisionId': '594f41fb-xmpl-4c20-95c7-6ca5f2a92c93',
        'RoutingConfig': {
            'AdditionalVersionWeights': {
                '1': 0.7,
            },
        },
        'ResponseMetadata': {
            '...': '...',
        },
    }

  