add_layer_version_permission
¶
add_layer_version_permission(
layer_name: LayerName,
version_number: LayerVersionNumber,
statement_id: StatementId,
action: LayerPermissionAllowedAction,
principal: LayerPermissionAllowedPrincipal,
*,
config_overrides: Optional[LambdaClientConfig] = 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.
>>> 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/_lambda.py
6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 | |