Skip to content

Adds a resource-based policy to a Lambda resource

Description

Adds a resource-based policy to a Lambda resource. Resource-based policies grant access to other Amazon Web Services accounts, organizations, or services. Resource-based policies apply to a single Lambda resource (for example, a function, function version, or function alias).

This operation replaces any existing policy on the Lambda resource. If you previously added permissions using the add_permission operation, the new policy overwrites those permissions.

Usage

lambda_put_resource_policy(ResourceArn, Policy, RevisionId)

Arguments

  • ResourceArn

[required] The Amazon Resource Name (ARN) of the Lambda resource you want to add the policy to. You can use a qualified or an unqualified ARN. The value must be a complete ARN, and the operation does not accept wildcard characters.

  • Policy

[required] The policy document you want to add to your Lambda resource. This is formatted as a JSON string.

For more information, see Working with resource-based policies in Lambda in the Lambda Developer Guide.

  • RevisionId

The revision ID that the existing policy must match for the replacement to proceed. If the revision ID doesn't match, the operation fails with a PreconditionFailedException error. To retrieve the current revision ID, use the get_resource_policy operation.

Value

A list with the following syntax:

list(
  Policy = "string",
  RevisionId = "string"
)

Request syntax

svc$put_resource_policy(
  ResourceArn = "string",
  Policy = "string",
  RevisionId = "string"
)