add_layer_version_permission
async
¶
add_layer_version_permission(
layer_name: LayerName,
version_number: LayerVersionNumber,
statement_id: StatementId,
action: LayerPermissionAllowedAction,
principal: LayerPermissionAllowedPrincipal,
*,
config_overrides: Optional[AsyncLambdaClientConfig] = None,
organization_id: Optional[OrganizationId] = None,
revision_id: Optional[String] = None,
) -> AddLayerVersionPermissionResponse
Adds permissions to the resource-based policy of a version of an Lambda layer. Use this action to grant layer usage permission to other accounts. You can grant permission to a single account, all accounts in an organization, or all Amazon Web Services accounts.
To revoke permission, call RemoveLayerVersionPermission with the statement ID that you specified when you added it.
Parameters:
-
layer_name(LayerName) –The name or Amazon Resource Name (ARN) of the layer.
-
version_number(LayerVersionNumber) –The version number.
-
statement_id(StatementId) –An identifier that distinguishes the policy from others on the same layer version.
-
action(LayerPermissionAllowedAction) –The API action that grants access to the layer. For example,
lambda:GetLayerVersion. -
principal(LayerPermissionAllowedPrincipal) –An account ID, or
*to grant layer usage permission to all accounts in an organization, or all Amazon Web Services accounts (iforganizationIdis not specified). For the last case, make sure that you really do want all Amazon Web Services accounts to have usage permission to this layer. -
organization_id(Optional[OrganizationId], default:None) –With the principal set to
*, grant permission to all accounts in the specified organization. -
revision_id(Optional[String], default:None) –Only update the policy if the revision ID matches the ID 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.
-
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.
-
-
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.
Examples:
To add permissions to a layer version The following example grants permission for the account 223456789012 to use version 1 of a layer named my-layer.
>>> await client.add_layer_version_permission(action='lambda:GetLayerVersion', layer_name='my-layer', principal='223456789012', statement_id='xaccount', version_number=1)
Source code in docs_src/capo_lambda/_services/async__lambda.py
6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 | |