publishLayerVersion method

Future<PublishLayerVersionResponse> publishLayerVersion({
  1. required LayerVersionContentInput content,
  2. required String layerName,
  3. List<Runtime>? compatibleRuntimes,
  4. String? description,
  5. String? licenseInfo,
})

Creates an AWS Lambda layer from a ZIP archive. Each time you call PublishLayerVersion with the same layer name, a new version is created.

Add layers to your function with CreateFunction or UpdateFunctionConfiguration.

May throw ServiceException. May throw ResourceNotFoundException. May throw TooManyRequestsException. May throw InvalidParameterValueException. May throw CodeStorageExceededException.

Parameter content : The function layer archive.

Parameter layerName : The name or Amazon Resource Name (ARN) of the layer.

Parameter compatibleRuntimes : A list of compatible function runtimes. Used for filtering with ListLayers and ListLayerVersions.

Parameter description : The description of the version.

Parameter licenseInfo : The layer's software license. It can be any of the following:

  • An SPDX license identifier. For example, MIT.
  • The URL of a license hosted on the internet. For example, https://opensource.org/licenses/MIT.
  • The full text of the license.

Implementation

Future<PublishLayerVersionResponse> publishLayerVersion({
  required LayerVersionContentInput content,
  required String layerName,
  List<Runtime>? compatibleRuntimes,
  String? description,
  String? licenseInfo,
}) async {
  ArgumentError.checkNotNull(content, 'content');
  ArgumentError.checkNotNull(layerName, 'layerName');
  _s.validateStringLength(
    'layerName',
    layerName,
    1,
    140,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    256,
  );
  _s.validateStringLength(
    'licenseInfo',
    licenseInfo,
    0,
    512,
  );
  final $payload = <String, dynamic>{
    'Content': content,
    if (compatibleRuntimes != null)
      'CompatibleRuntimes':
          compatibleRuntimes.map((e) => e.toValue()).toList(),
    if (description != null) 'Description': description,
    if (licenseInfo != null) 'LicenseInfo': licenseInfo,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/2018-10-31/layers/${Uri.encodeComponent(layerName)}/versions',
    exceptionFnMap: _exceptionFns,
  );
  return PublishLayerVersionResponse.fromJson(response);
}