Skip to content

update_function_configuration async

update_function_configuration(
    function_name: FunctionName,
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    role: Optional[RoleArn] = None,
    handler: Optional[Handler] = None,
    description: Optional[Description] = None,
    timeout: Optional[Timeout] = None,
    memory_size: Optional[MemorySize] = None,
    vpc_config: Optional[VpcConfig] = None,
    environment: Optional[Environment] = None,
    runtime: Optional[Runtime] = None,
    dead_letter_config: Optional[DeadLetterConfig] = None,
    kms_key_arn: Optional[KMSKeyArn] = None,
    tracing_config: Optional[TracingConfig] = None,
    revision_id: Optional[String] = None,
    layers: Optional[LayerList] = None,
    file_system_configs: Optional[FileSystemConfigList] = None,
    image_config: Optional[ImageConfig] = None,
    ephemeral_storage: Optional[EphemeralStorage] = None,
    snap_start: Optional[SnapStart] = None,
    logging_config: Optional[LoggingConfig] = None,
    capacity_provider_config: Optional[CapacityProviderConfig] = None,
    durable_config: Optional[DurableConfig] = None,
) -> FunctionConfiguration

Modifies the version-specific settings of a Lambda Event Function.

When you update a function, Lambda provisions an instance of the function and its supporting resources. If your function connects to a VPC, this process can take a minute. During this time, you can't modify the function, but you can still invoke it. The LastUpdateStatus, LastUpdateStatusReason, and LastUpdateStatusReasonCode fields in the response from GetFunctionConfiguration indicate when the update is complete and the function is processing events with the new configuration. For more information, see Lambda function states.

These settings can vary between versions of a function and are locked when you publish a version. You can't modify the configuration of a published version, only the unpublished version.

To configure function concurrency, use PutFunctionConcurrency. To grant invoke permissions to an Amazon Web Services account or Amazon Web Services service, use AddPermission.

Parameters:

  • function_name (FunctionName) –

    The name or ARN of the Lambda function.

    Name formats

    • Function name – my-function.

    • Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function.

    • Partial ARN – 123456789012:function:my-function.

    The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

  • role (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the function's execution role.

  • handler (Optional[Handler], default: None ) –

    The name of the method within your code that Lambda calls to run your function. Handler is required if the deployment package is a .zip file archive. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see Lambda programming model.

  • description (Optional[Description], default: None ) –

    A description of the function.

  • timeout (Optional[Timeout], default: None ) –

    The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds, and the maximum allowed value is 900 seconds. For functions using Lambda Managed Instances, asynchronous invocations and event source mapping invocations (except Amazon MQ and Amazon DocumentDB) support a maximum allowed value of 5,400 seconds (90 minutes). For more information, see Lambda execution environment.

  • memory_size (Optional[MemorySize], default: None ) –

    The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB.

  • vpc_config (Optional[VpcConfig], default: None ) –

    For network connectivity to Amazon Web Services resources in a VPC, specify a list of security groups and subnets in the VPC. When you connect a function to a VPC, it can access resources and the internet only through that VPC. For more information, see Configuring a Lambda function to access resources in a VPC.

  • environment (Optional[Environment], default: None ) –

    Environment variables that are accessible from function code during execution.

  • runtime (Optional[Runtime], default: None ) –

    The identifier of the function's runtime. Runtime is required if the deployment package is a .zip file archive. Specifying a runtime results in an error if you're deploying a function using a container image.

    The following list includes deprecated runtimes. Lambda blocks creating new functions and updating existing functions shortly after each runtime is deprecated. For more information, see Runtime use after deprecation.

    For a list of all currently supported runtimes, see Supported runtimes.

  • dead_letter_config (Optional[DeadLetterConfig], default: None ) –

    A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing. For more information, see Dead-letter queues.

  • kms_key_arn (Optional[KMSKeyArn], default: None ) –

    The ARN of the Key Management Service (KMS) customer managed key that's used to encrypt the following resources:

    • The function's environment variables.

    • The function's Lambda SnapStart snapshots.

    • When used with SourceKMSKeyArn, the unzipped version of the .zip deployment package that's used for function invocations. For more information, see Specifying a customer managed key for Lambda.

    • The optimized version of the container image that's used for function invocations. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). For more information, see Function lifecycle.

    If you don't provide a customer managed key, Lambda uses an Amazon Web Services owned key or an Amazon Web Services managed key.

  • tracing_config (Optional[TracingConfig], default: None ) –

    Set Mode to Active to sample and trace a subset of incoming requests with X-Ray.

  • revision_id (Optional[String], default: None ) –

    Update the function only if the revision ID matches the ID that's specified. Use this option to avoid modifying a function that has changed since you last read it.

  • layers (Optional[LayerList], default: None ) –

    A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.

  • file_system_configs (Optional[FileSystemConfigList], default: None ) –

    Connection settings for an Amazon EFS file system or an Amazon S3 Files file system.

  • image_config (Optional[ImageConfig], default: None ) –

    Container image configuration values that override the values in the container image Docker file.

  • ephemeral_storage (Optional[EphemeralStorage], default: None ) –

    The size of the function's /tmp directory in MB. The default value is 512, but can be any whole number between 512 and 10,240 MB. For more information, see Configuring ephemeral storage (console).

  • snap_start (Optional[SnapStart], default: None ) –

    The function's SnapStart setting.

  • logging_config (Optional[LoggingConfig], default: None ) –

    The function's Amazon CloudWatch Logs configuration settings.

  • capacity_provider_config (Optional[CapacityProviderConfig], default: None ) –

    Configuration for the capacity provider that manages compute resources for Lambda functions.

  • durable_config (Optional[DurableConfig], default: None ) –

    Configuration settings for durable functions, including execution timeout, retention period for execution history, and an optional ARN of the Key Management Service (KMS) customer managed key that is used to encrypt your durable execution's payload data, including input, output, and error payloads.

Raises:

  • CodeSigningConfigNotFoundException –

    The specified code signing configuration does not exist.

  • CodeVerificationFailedException –

    The code signature failed one or more of the validation checks for signature mismatch or expiry, and the code signing policy is set to ENFORCE. Lambda blocks the deployment.

  • InvalidCodeSignatureException –

    The code signature failed the integrity check. If the integrity check fails, then Lambda blocks deployment, even if the code signing policy is set to WARN.

  • InvalidParameterValueException –

    One of the parameters in the request is not valid.

  • PreconditionFailedException –

    The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.

    • For AddPermission and RemovePermission API operations: Call GetPolicy to retrieve the latest RevisionId for your resource.

    • For all other API operations: Call GetFunction or GetAlias to 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 update a Lambda function's configuration The following example modifies the memory size to be 256 MB for the unpublished ($LATEST) version of a function named my-function.

>>> await client.update_function_configuration(durable_config={'ExecutionTimeout': 3600, 'RetentionPeriodInDays': 45}, function_name='my-function', memory_size=256)
Source code in docs_src/capo_lambda/_services/async__lambda.py
async def update_function_configuration(
    self,
    function_name: "capo_lambda.types.function_name.FunctionName",
    *,
    config_overrides: Optional[AsyncLambdaClientConfig] = None,
    role: Optional["capo_lambda.types.role_arn.RoleArn"] = None,
    handler: Optional["capo_lambda.types.handler.Handler"] = None,
    description: Optional["capo_lambda.types.description.Description"] = None,
    timeout: Optional["capo_lambda.types.timeout.Timeout"] = None,
    memory_size: Optional["capo_lambda.types.memory_size.MemorySize"] = None,
    vpc_config: Optional["capo_lambda.types.vpc_config.VpcConfig"] = None,
    environment: Optional["capo_lambda.types.environment.Environment"] = None,
    runtime: Optional["capo_lambda.types.runtime.Runtime"] = None,
    dead_letter_config: Optional[
        "capo_lambda.types.dead_letter_config.DeadLetterConfig"
    ] = None,
    kms_key_arn: Optional["capo_lambda.types.kms_key_arn.KMSKeyArn"] = None,
    tracing_config: Optional[
        "capo_lambda.types.tracing_config.TracingConfig"
    ] = None,
    revision_id: Optional["capo_lambda.types.string.String"] = None,
    layers: Optional["capo_lambda.types.layer_list.LayerList"] = None,
    file_system_configs: Optional[
        "capo_lambda.types.file_system_config_list.FileSystemConfigList"
    ] = None,
    image_config: Optional["capo_lambda.types.image_config.ImageConfig"] = None,
    ephemeral_storage: Optional[
        "capo_lambda.types.ephemeral_storage.EphemeralStorage"
    ] = None,
    snap_start: Optional["capo_lambda.types.snap_start.SnapStart"] = None,
    logging_config: Optional[
        "capo_lambda.types.logging_config.LoggingConfig"
    ] = None,
    capacity_provider_config: Optional[
        "capo_lambda.types.capacity_provider_config.CapacityProviderConfig"
    ] = None,
    durable_config: Optional[
        "capo_lambda.types.durable_config.DurableConfig"
    ] = None,
) -> "capo_lambda.types.function_configuration.FunctionConfiguration":
    """<p>Modifies the version-specific settings of a Lambda Event Function.</p> <p>When you update a function, Lambda provisions an instance of the function and its supporting resources. If your function connects to a VPC, this process can take a minute. During this time, you can't modify the function, but you can still invoke it. The <code>LastUpdateStatus</code>, <code>LastUpdateStatusReason</code>, and <code>LastUpdateStatusReasonCode</code> fields in the response from <a>GetFunctionConfiguration</a> indicate when the update is complete and the function is processing events with the new configuration. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/functions-states.html">Lambda function states</a>.</p> <p>These settings can vary between versions of a function and are locked when you publish a version. You can't modify the configuration of a published version, only the unpublished version.</p> <p>To configure function concurrency, use <a>PutFunctionConcurrency</a>. To grant invoke permissions to an Amazon Web Services account or Amazon Web Services service, use <a>AddPermission</a>.</p>

    Args:
        function_name: <p>The name or ARN of the Lambda function.</p> <p class="title"> <b>Name formats</b> </p> <ul> <li> <p> <b>Function name</b> – <code>my-function</code>.</p> </li> <li> <p> <b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p> </li> <li> <p> <b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p> </li> </ul> <p>The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
        role: <p>The Amazon Resource Name (ARN) of the function's execution role.</p>
        handler: <p>The name of the method within your code that Lambda calls to run your function. Handler is required if the deployment package is a .zip file archive. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/foundation-progmodel.html">Lambda programming model</a>.</p>
        description: <p>A description of the function.</p>
        timeout: <p>The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds, and the maximum allowed value is 900 seconds. For functions using Lambda Managed Instances, asynchronous invocations and event source mapping invocations (except Amazon MQ and Amazon DocumentDB) support a maximum allowed value of 5,400 seconds (90 minutes). For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html">Lambda execution environment</a>.</p>
        memory_size: <p>The amount of <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console">memory available to the function</a> at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB.</p>
        vpc_config: <p>For network connectivity to Amazon Web Services resources in a VPC, specify a list of security groups and subnets in the VPC. When you connect a function to a VPC, it can access resources and the internet only through that VPC. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html">Configuring a Lambda function to access resources in a VPC</a>.</p>
        environment: <p>Environment variables that are accessible from function code during execution.</p>
        runtime: <p>The identifier of the function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html"> runtime</a>. Runtime is required if the deployment package is a .zip file archive. Specifying a runtime results in an error if you're deploying a function using a container image.</p> <p>The following list includes deprecated runtimes. Lambda blocks creating new functions and updating existing functions shortly after each runtime is deprecated. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels">Runtime use after deprecation</a>.</p> <p>For a list of all currently supported runtimes, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported">Supported runtimes</a>.</p>
        dead_letter_config: <p>A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq">Dead-letter queues</a>.</p>
        kms_key_arn: <p>The ARN of the Key Management Service (KMS) customer managed key that's used to encrypt the following resources:</p> <ul> <li> <p>The function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption">environment variables</a>.</p> </li> <li> <p>The function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/snapstart-security.html">Lambda SnapStart</a> snapshots.</p> </li> <li> <p>When used with <code>SourceKMSKeyArn</code>, the unzipped version of the .zip deployment package that's used for function invocations. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/encrypt-zip-package.html#enable-zip-custom-encryption"> Specifying a customer managed key for Lambda</a>.</p> </li> <li> <p>The optimized version of the container image that's used for function invocations. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-lifecycle">Function lifecycle</a>.</p> </li> </ul> <p>If you don't provide a customer managed key, Lambda uses an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-owned-cmk">Amazon Web Services owned key</a> or an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk">Amazon Web Services managed key</a>.</p>
        tracing_config: <p>Set <code>Mode</code> to <code>Active</code> to sample and trace a subset of incoming requests with <a href="https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html">X-Ray</a>.</p>
        revision_id: <p>Update the function only if the revision ID matches the ID that's specified. Use this option to avoid modifying a function that has changed since you last read it.</p>
        layers: <p>A list of <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html">function layers</a> to add to the function's execution environment. Specify each layer by its ARN, including the version.</p>
        file_system_configs: <p>Connection settings for an Amazon EFS file system or an Amazon S3 Files file system.</p>
        image_config: <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-parms">Container image configuration values</a> that override the values in the container image Docker file.</p>
        ephemeral_storage: <p>The size of the function's <code>/tmp</code> directory in MB. The default value is 512, but can be any whole number between 512 and 10,240 MB. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-ephemeral-storage">Configuring ephemeral storage (console)</a>.</p>
        snap_start: <p>The function's <a href="https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html">SnapStart</a> setting.</p>
        logging_config: <p>The function's Amazon CloudWatch Logs configuration settings.</p>
        capacity_provider_config: <p>Configuration for the capacity provider that manages compute resources for Lambda functions.</p>
        durable_config: <p>Configuration settings for <a href="https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html">durable functions</a>, including execution timeout, retention period for execution history, and an optional ARN of the Key Management Service (KMS) customer managed key that is used to encrypt your durable execution's payload data, including input, output, and error payloads.</p>

    Raises:
        capo_lambda.errors.code_signing_config_not_found_exception.CodeSigningConfigNotFoundException: <p>The specified code signing configuration does not exist.</p>
        capo_lambda.errors.code_verification_failed_exception.CodeVerificationFailedException: <p>The code signature failed one or more of the validation checks for signature mismatch or expiry, and the code signing policy is set to ENFORCE. Lambda blocks the deployment.</p>
        capo_lambda.errors.invalid_code_signature_exception.InvalidCodeSignatureException: <p>The code signature failed the integrity check. If the integrity check fails, then Lambda blocks deployment, even if the code signing policy is set to WARN.</p>
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.precondition_failed_exception.PreconditionFailedException: <p>The RevisionId provided does not match the latest RevisionId for the Lambda function or alias.</p> <ul> <li> <p> <b>For AddPermission and RemovePermission API operations:</b> Call <code>GetPolicy</code> to retrieve the latest RevisionId for your resource.</p> </li> <li> <p> <b>For all other API operations:</b> Call <code>GetFunction</code> or <code>GetAlias</code> to retrieve the latest RevisionId for your resource.</p> </li> </ul>
        capo_lambda.errors.resource_conflict_exception.ResourceConflictException: <p>The resource already exists, or another operation is in progress.</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 update a Lambda function's configuration
        The following example modifies the memory size to be 256 MB for the unpublished ($LATEST) version of a function named my-function.

        >>> await client.update_function_configuration(durable_config={'ExecutionTimeout': 3600, 'RetentionPeriodInDays': 45}, function_name='my-function', memory_size=256)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lambda.types.update_function_configuration_request.UpdateFunctionConfigurationRequest]",
    ) -> AsyncOperationResponse[
        "capo_lambda.types.function_configuration.FunctionConfiguration"
    ]:
        import capo_lambda._operations.aws_gir_api_service.update_function_configuration

        (
            output,
            http_response,
        ) = await capo_lambda._operations.aws_gir_api_service.update_function_configuration.async_update_function_configuration(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

        return capo_lambda.types.update_function_configuration_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_lambda.types.function_configuration.FunctionConfiguration",
    ) -> dict[str, Any]:
        import capo_lambda.types.function_configuration

        return capo_lambda.types.function_configuration.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateFunctionConfiguration",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_lambda.types.update_function_configuration_request.UpdateFunctionConfigurationRequest = {
        "function_name": function_name
    }
    if role is not None:
        input_["role"] = role
    if handler is not None:
        input_["handler"] = handler
    if description is not None:
        input_["description"] = description
    if timeout is not None:
        input_["timeout"] = timeout
    if memory_size is not None:
        input_["memory_size"] = memory_size
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if environment is not None:
        input_["environment"] = environment
    if runtime is not None:
        input_["runtime"] = runtime
    if dead_letter_config is not None:
        input_["dead_letter_config"] = dead_letter_config
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn
    if tracing_config is not None:
        input_["tracing_config"] = tracing_config
    if revision_id is not None:
        input_["revision_id"] = revision_id
    if layers is not None:
        input_["layers"] = layers
    if file_system_configs is not None:
        input_["file_system_configs"] = file_system_configs
    if image_config is not None:
        input_["image_config"] = image_config
    if ephemeral_storage is not None:
        input_["ephemeral_storage"] = ephemeral_storage
    if snap_start is not None:
        input_["snap_start"] = snap_start
    if logging_config is not None:
        input_["logging_config"] = logging_config
    if capacity_provider_config is not None:
        input_["capacity_provider_config"] = capacity_provider_config
    if durable_config is not None:
        input_["durable_config"] = durable_config

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output