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

**********
get_policy
**********



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

  

  Returns the `resource-based IAM policy <https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html>`__ for a function, version, or alias.

  

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


  **Request Syntax**
  ::

    response = client.get_policy(
        FunctionName='string',
        Qualifier='string'
    )
    
  :type FunctionName: string
  :param FunctionName: **[REQUIRED]** 

    The name or ARN of the Lambda function, version, or alias.

     

    **Name formats**

     

    
    * **Function name** – ``my-function`` (name-only), ``my-function:v1`` (with alias).
     
    * **Function ARN** – ``arn:aws:lambda:us-west-2:123456789012:function:my-function``.
     
    * **Partial ARN** – ``123456789012:function:my-function``.
    

     

    You can append a version number or alias to any of the formats. 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 Qualifier: string
  :param Qualifier: 

    Specify a version or alias to get the policy for that resource.

    

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

    
    ::

      {
          'Policy': 'string',
          'RevisionId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Policy** *(string) --* 

        The resource-based policy.

        
      

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

        A unique identifier for the current revision of the policy.

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

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

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

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

  

  **Examples**

  The following example returns the resource-based policy for version 1 of a Lambda function named my-function.
  ::

    response = client.get_policy(
        FunctionName='my-function',
        Qualifier='1',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'Policy': '{"Version":"2012-10-17","Id":"default","Statement":[{"Sid":"xaccount","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"},"Action":"lambda:InvokeFunction","Resource":"arn:aws:lambda:us-east-2:123456789012:function:my-function:1"}]}',
        'RevisionId': '4843f2f6-7c59-4fda-b484-afd0bc0e22b8',
        'ResponseMetadata': {
            '...': '...',
        },
    }

  