put_resource_policy
¶
put_resource_policy(
resource_arn: PolicyResourceArn,
policy: ResourcePolicy,
*,
config_overrides: Optional[LambdaClientConfig] = None,
revision_id: Optional[RevisionId] = None,
) -> PutResourcePolicyResponse
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 AddPermission operation, the new policy overwrites those permissions.
Parameters:
-
resource_arn(PolicyResourceArn) –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(ResourcePolicy) –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.
-
revision_id(Optional[RevisionId], default:None) –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
PreconditionFailedExceptionerror. To retrieve the current revision ID, use the GetResourcePolicy operation.
Raises:
-
InvalidParameterValueException–One of the parameters in the request is not valid.
-
PolicyLengthExceededException–The permissions policy for the resource is too large. For more information, see Lambda quotas.
-
PreconditionFailedException–The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.
-
For AddPermission and RemovePermission API operations: Call
GetPolicyto retrieve the latest RevisionId for your resource. -
For all other API operations: Call
GetFunctionorGetAliasto 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.
-
ResourceConflictException–The resource already exists, or another operation is in progress.
-
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.