Skip to content

remove_permission async

remove_permission(
    function_name: NamespacedFunctionName,
    statement_id: NamespacedStatementId,
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    qualifier: Optional[NumericLatestPublishedOrAliasQualifier] = None,
    revision_id: Optional[String] = None,
) -> None

Revokes function-use permission from an Amazon Web Services service or another Amazon Web Services account. You can get the ID of the statement from the output of GetPolicy.

Parameters:

  • function_name (NamespacedFunctionName) –

    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.

  • statement_id (NamespacedStatementId) –

    Statement ID of the permission to remove.

  • qualifier (Optional[NumericLatestPublishedOrAliasQualifier], default: None ) –

    Specify a version or alias to remove permissions from a published version of the function.

  • revision_id (Optional[String], default: None ) –

    Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.

Raises:

  • InvalidParameterValueException –

    One of the parameters in the request is not valid.

  • PreconditionFailedException –

    The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.

    • For AddPermission and RemovePermission API operations: Call GetPolicy to retrieve the latest RevisionId for your resource.

    • For all other API operations: Call GetFunction or GetAlias to retrieve the latest RevisionId for your resource.

  • PublicPolicyException –

    The resource-based policy you tried to add to the Lambda resource would grant public access to it, which isn't allowed.

  • ResourceNotFoundException –

    The resource specified in the request does not exist.

  • ServiceException –

    The Lambda service encountered an internal error.

  • TooManyRequestsException –

    The request throughput limit was exceeded. For more information, see Lambda quotas.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To remove a Lambda function's permissions The following example removes a permissions statement named xaccount from the PROD alias of a function named my-function.

>>> await client.remove_permission(function_name='my-function', qualifier='PROD', statement_id='xaccount')
Source code in docs_src/capo_lambda/_services/async__lambda.py
async def remove_permission(
    self,
    function_name: "capo_lambda.types.namespaced_function_name.NamespacedFunctionName",
    statement_id: "capo_lambda.types.namespaced_statement_id.NamespacedStatementId",
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    qualifier: Optional[
        "capo_lambda.types.numeric_latest_published_or_alias_qualifier.NumericLatestPublishedOrAliasQualifier"
    ] = None,
    revision_id: Optional["capo_lambda.types.string.String"] = None,
) -> None:
    """<p>Revokes function-use permission from an Amazon Web Services service or another Amazon Web Services account. You can get the ID of the statement from the output of <a>GetPolicy</a>.</p>

    Args:
        function_name: <p>The name or ARN of the Lambda function, version, or alias.</p> <p class="title"> <b>Name formats</b> </p> <ul> <li> <p> <b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p> </li> <li> <p> <b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p> </li> <li> <p> <b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p> </li> </ul> <p>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.</p>
        statement_id: <p>Statement ID of the permission to remove.</p>
        qualifier: <p>Specify a version or alias to remove permissions from a published version of the function.</p>
        revision_id: <p>Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.</p>

    Raises:
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.precondition_failed_exception.PreconditionFailedException: <p>The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.</p> <ul> <li> <p> <b>For AddPermission and RemovePermission API operations:</b> Call <code>GetPolicy</code> to retrieve the latest RevisionId for your resource.</p> </li> <li> <p> <b>For all other API operations:</b> Call <code>GetFunction</code> or <code>GetAlias</code> to retrieve the latest RevisionId for your resource.</p> </li> </ul>
        capo_lambda.errors.public_policy_exception.PublicPolicyException: <p>The resource-based policy you tried to add to the Lambda resource would grant public access to it, which isn't allowed.</p>
        capo_lambda.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request does not exist.</p>
        capo_lambda.errors.service_exception.ServiceException: <p>The Lambda service encountered an internal error.</p>
        capo_lambda.errors.too_many_requests_exception.TooManyRequestsException: <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
        capo_lambda.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To remove a Lambda function's permissions
        The following example removes a permissions statement named xaccount from the PROD alias of a function named my-function.

        >>> await client.remove_permission(function_name='my-function', qualifier='PROD', statement_id='xaccount')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lambda.types.remove_permission_request.RemovePermissionRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_lambda._operations.aws_gir_api_service.remove_permission

        (
            output,
            http_response,
        ) = await capo_lambda._operations.aws_gir_api_service.remove_permission.async_remove_permission(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RemovePermission")
    )
    input_: capo_lambda.types.remove_permission_request.RemovePermissionRequest = {
        "function_name": function_name,
        "statement_id": statement_id,
    }
    if qualifier is not None:
        input_["qualifier"] = qualifier
    if revision_id is not None:
        input_["revision_id"] = revision_id

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output