Skip to content

publish_layer_version

publish_layer_version(
    layer_name: LayerName,
    content: LayerVersionContentInput,
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    description: Optional[Description] = None,
    compatible_architectures: Optional[CompatibleArchitectures] = None,
    compatible_runtimes: Optional[CompatibleRuntimes] = None,
    license_info: Optional[LicenseInfo] = None,
) -> PublishLayerVersionResponse

Creates an 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.

Parameters:

Raises:

Examples:

To create a Lambda layer version The following example creates a new Python library layer version. The command retrieves the layer content a file named layer.zip in the specified S3 bucket.

>>> client.publish_layer_version(compatible_runtimes=['python3.6', 'python3.7'], content={'S3Bucket': 'lambda-layers-us-west-2-123456789012', 'S3Key': 'layer.zip'}, description='My Python layer', layer_name='my-layer', license_info='MIT')
Source code in docs_src/capo_lambda/_services/_lambda.py
def publish_layer_version(
    self,
    layer_name: "capo_lambda.types.layer_name.LayerName",
    content: "capo_lambda.types.layer_version_content_input.LayerVersionContentInput",
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    description: Optional["capo_lambda.types.description.Description"] = None,
    compatible_architectures: Optional[
        "capo_lambda.types.compatible_architectures.CompatibleArchitectures"
    ] = None,
    compatible_runtimes: Optional[
        "capo_lambda.types.compatible_runtimes.CompatibleRuntimes"
    ] = None,
    license_info: Optional["capo_lambda.types.license_info.LicenseInfo"] = None,
) -> "capo_lambda.types.publish_layer_version_response.PublishLayerVersionResponse":
    """<p>Creates an <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html">Lambda layer</a> from a ZIP archive. Each time you call <code>PublishLayerVersion</code> with the same layer name, a new version is created.</p> <p>Add layers to your function with <a>CreateFunction</a> or <a>UpdateFunctionConfiguration</a>.</p>

    Args:
        layer_name: <p>The name or Amazon Resource Name (ARN) of the layer.</p>
        description: <p>The description of the version.</p>
        content: <p>The function layer archive.</p>
        compatible_architectures: <p>A list of compatible <a href="https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html">instruction set architectures</a>.</p>
        compatible_runtimes: <p>A list of compatible <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html">function runtimes</a>. Used for filtering with <a>ListLayers</a> and <a>ListLayerVersions</a>.</p> <p>The following list includes deprecated runtimes. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-support-policy">Runtime deprecation policy</a>.</p>
        license_info: <p>The layer's software license. It can be any of the following:</p> <ul> <li> <p>An <a href="https://spdx.org/licenses/">SPDX license identifier</a>. For example, <code>MIT</code>.</p> </li> <li> <p>The URL of a license hosted on the internet. For example, <code>https://opensource.org/licenses/MIT</code>.</p> </li> <li> <p>The full text of the license.</p> </li> </ul>

    Raises:
        capo_lambda.errors.code_storage_exceeded_exception.CodeStorageExceededException: <p>Your Amazon Web Services account has exceeded its maximum total code size. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">Lambda quotas</a>.</p>
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request does not exist.</p>
        capo_lambda.errors.service_exception.ServiceException: <p>The Lambda service encountered an internal error.</p>
        capo_lambda.errors.too_many_requests_exception.TooManyRequestsException: <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
        capo_lambda.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a Lambda layer version
        The following example creates a new Python library layer version. The command retrieves the layer content a file named layer.zip in the specified S3 bucket.

        >>> client.publish_layer_version(compatible_runtimes=['python3.6', 'python3.7'], content={'S3Bucket': 'lambda-layers-us-west-2-123456789012', 'S3Key': 'layer.zip'}, description='My Python layer', layer_name='my-layer', license_info='MIT')
    """

    def _handler(
        req: "OperationRequest[capo_lambda.types.publish_layer_version_request.PublishLayerVersionRequest]",
    ) -> OperationResponse[
        "capo_lambda.types.publish_layer_version_response.PublishLayerVersionResponse"
    ]:
        import capo_lambda._operations.aws_gir_api_service.publish_layer_version

        output, http_response = (
            capo_lambda._operations.aws_gir_api_service.publish_layer_version.publish_layer_version(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_lambda.types.publish_layer_version_request.PublishLayerVersionRequest",
    ) -> dict[str, Any]:
        import capo_lambda.types.publish_layer_version_request

        return capo_lambda.types.publish_layer_version_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PublishLayerVersion", redact_input=_redact_input),
    )
    input_: capo_lambda.types.publish_layer_version_request.PublishLayerVersionRequest = {
        "layer_name": layer_name,
        "content": content,
    }
    if description is not None:
        input_["description"] = description
    if compatible_architectures is not None:
        input_["compatible_architectures"] = compatible_architectures
    if compatible_runtimes is not None:
        input_["compatible_runtimes"] = compatible_runtimes
    if license_info is not None:
        input_["license_info"] = license_info

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output