addLayerVersionPermission method
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.
May throw InvalidParameterValueException.
May throw PolicyLengthExceededException.
May throw PreconditionFailedException.
May throw ResourceConflictException.
May throw ResourceNotFoundException.
May throw ServiceException.
May throw TooManyRequestsException.
Parameter action :
The API action that grants access to the layer. For example,
lambda:GetLayerVersion.
Parameter layerName :
The name or Amazon Resource Name (ARN) of the layer.
Parameter principal :
An account ID, or * to grant layer usage permission to all
accounts in an organization, or all Amazon Web Services accounts (if
organizationId is 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.
Parameter statementId :
An identifier that distinguishes the policy from others on the same layer
version.
Parameter versionNumber :
The version number.
Parameter organizationId :
With the principal set to *, grant permission to all accounts
in the specified organization.
Parameter revisionId :
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.
Implementation
Future<AddLayerVersionPermissionResponse> addLayerVersionPermission({
required String action,
required String layerName,
required String principal,
required String statementId,
required int versionNumber,
String? organizationId,
String? revisionId,
}) async {
final $query = <String, List<String>>{
if (revisionId != null) 'RevisionId': [revisionId],
};
final $payload = <String, dynamic>{
'Action': action,
'Principal': principal,
'StatementId': statementId,
if (organizationId != null) 'OrganizationId': organizationId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/2018-10-31/layers/${Uri.encodeComponent(layerName)}/versions/${Uri.encodeComponent(versionNumber.toString())}/policy',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return AddLayerVersionPermissionResponse.fromJson(response);
}