Method: Aws::Lambda::Client#update_function_configuration
- Defined in:
- lib/aws-sdk-lambda/client.rb
#update_function_configuration(params = {}) ⇒ Types::FunctionConfiguration
Modify the version-specific settings of a Lambda 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.
[1]: docs.aws.amazon.com/lambda/latest/dg/functions-states.html
Examples:
Example: To update a Lambda function’s configuration
Example: 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.
resp = client.update_function_configuration({
durable_config: {
execution_timeout: 3600,
retention_period_in_days: 45,
},
function_name: "my-function",
memory_size: 256,
})
resp.to_h outputs the following:
{
code_sha_256: "PFn4S+er27qk+UuZSTKEQfNKG/XNn7QJs90mJgq6oH8=",
code_size: 308,
description: "",
durable_config: {
execution_timeout: 3600,
retention_period_in_days: 45,
},
function_arn: "arn:aws:lambda:us-east-2:123456789012:function:my-function",
function_name: "my-function",
handler: "index.handler",
last_modified: Time.parse("2019-08-14T22:26:11.234+0000"),
memory_size: 256,
revision_id: "873282ed-xmpl-4dc8-a069-d0c647e470c6",
role: "arn:aws:iam::123456789012:role/lambda-role",
runtime: "nodejs12.x",
timeout: 3,
tracing_config: {
mode: "PassThrough",
},
version: "$LATEST",
}
Request syntax with placeholder values
Request syntax with placeholder values
resp = client.update_function_configuration({
function_name: "FunctionName", # required
role: "RoleArn",
handler: "Handler",
description: "Description",
timeout: 1,
memory_size: 1,
vpc_config: {
subnet_ids: ["SubnetId"],
security_group_ids: ["SecurityGroupId"],
ipv_6_allowed_for_dual_stack: false,
},
environment: {
variables: {
"EnvironmentVariableName" => "EnvironmentVariableValue",
},
},
runtime: "nodejs", # accepts nodejs, nodejs4.3, nodejs6.10, nodejs8.10, nodejs10.x, nodejs12.x, nodejs14.x, nodejs16.x, java8, java8.al2, java11, python2.7, python3.6, python3.7, python3.8, python3.9, dotnetcore1.0, dotnetcore2.0, dotnetcore2.1, dotnetcore3.1, dotnet6, dotnet8, nodejs4.3-edge, go1.x, ruby2.5, ruby2.7, provided, provided.al2, nodejs18.x, python3.10, java17, ruby3.2, ruby3.3, ruby3.4, python3.11, nodejs20.x, provided.al2023, python3.12, java21, python3.13, nodejs22.x, nodejs24.x, python3.14, java25, dotnet10
dead_letter_config: {
target_arn: "ResourceArn",
},
kms_key_arn: "KMSKeyArn",
tracing_config: {
mode: "Active", # accepts Active, PassThrough
},
revision_id: "String",
layers: ["LayerVersionArn"],
file_system_configs: [
{
arn: "FileSystemArn", # required
local_mount_path: "LocalMountPath", # required
},
],
image_config: {
entry_point: ["String"],
command: ["String"],
working_directory: "WorkingDirectory",
},
ephemeral_storage: {
size: 1, # required
},
snap_start: {
apply_on: "PublishedVersions", # accepts PublishedVersions, None
},
logging_config: {
log_format: "JSON", # accepts JSON, Text
application_log_level: "TRACE", # accepts TRACE, DEBUG, INFO, WARN, ERROR, FATAL
system_log_level: "DEBUG", # accepts DEBUG, INFO, WARN
log_group: "LogGroup",
},
capacity_provider_config: {
lambda_managed_instances_capacity_provider_config: { # required
capacity_provider_arn: "CapacityProviderArn", # required
per_execution_environment_max_concurrency: 1,
execution_environment_memory_gi_b_per_v_cpu: 1.0,
},
},
durable_config: {
retention_period_in_days: 1,
execution_timeout: 1,
},
})
Response structure
Response structure
resp.function_name #=> String
resp.function_arn #=> String
resp.runtime #=> String, one of "nodejs", "nodejs4.3", "nodejs6.10", "nodejs8.10", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "java8", "java8.al2", "java11", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "dotnet6", "dotnet8", "nodejs4.3-edge", "go1.x", "ruby2.5", "ruby2.7", "provided", "provided.al2", "nodejs18.x", "python3.10", "java17", "ruby3.2", "ruby3.3", "ruby3.4", "python3.11", "nodejs20.x", "provided.al2023", "python3.12", "java21", "python3.13", "nodejs22.x", "nodejs24.x", "python3.14", "java25", "dotnet10"
resp.role #=> String
resp.handler #=> String
resp.code_size #=> Integer
resp.description #=> String
resp.timeout #=> Integer
resp.memory_size #=> Integer
resp.last_modified #=> Time
resp.code_sha_256 #=> String
resp.version #=> String
resp.vpc_config.subnet_ids #=> Array
resp.vpc_config.subnet_ids[0] #=> String
resp.vpc_config.security_group_ids #=> Array
resp.vpc_config.security_group_ids[0] #=> String
resp.vpc_config.vpc_id #=> String
resp.vpc_config.ipv_6_allowed_for_dual_stack #=> Boolean
resp.dead_letter_config.target_arn #=> String
resp.environment.variables #=> Hash
resp.environment.variables["EnvironmentVariableName"] #=> String
resp.environment.error.error_code #=> String
resp.environment.error.message #=> String
resp.kms_key_arn #=> String
resp.tracing_config.mode #=> String, one of "Active", "PassThrough"
resp.master_arn #=> String
resp.revision_id #=> String
resp.layers #=> Array
resp.layers[0].arn #=> String
resp.layers[0].code_size #=> Integer
resp.layers[0].signing_profile_version_arn #=> String
resp.layers[0].signing_job_arn #=> String
resp.state #=> String, one of "Pending", "Active", "Inactive", "Failed", "Deactivating", "Deactivated", "ActiveNonInvocable", "Deleting"
resp.state_reason #=> String
resp.state_reason_code #=> String, one of "Idle", "Creating", "Restoring", "EniLimitExceeded", "InsufficientRolePermissions", "InvalidConfiguration", "InternalError", "SubnetOutOfIPAddresses", "InvalidSubnet", "InvalidSecurityGroup", "ImageDeleted", "ImageAccessDenied", "InvalidImage", "KMSKeyAccessDenied", "KMSKeyNotFound", "InvalidStateKMSKey", "DisabledKMSKey", "EFSIOError", "EFSMountConnectivityError", "EFSMountFailure", "EFSMountTimeout", "InvalidRuntime", "InvalidZipFileException", "FunctionError", "DrainingDurableExecutions", "VcpuLimitExceeded", "CapacityProviderScalingLimitExceeded", "InsufficientCapacity", "EC2RequestLimitExceeded", "FunctionError.InitTimeout", "FunctionError.RuntimeInitError", "FunctionError.ExtensionInitError", "FunctionError.InvalidEntryPoint", "FunctionError.InvalidWorkingDirectory", "FunctionError.PermissionDenied", "FunctionError.TooManyExtensions", "FunctionError.InitResourceExhausted", "DisallowedByVpcEncryptionControl"
resp.last_update_status #=> String, one of "Successful", "Failed", "InProgress"
resp.last_update_status_reason #=> String
resp.last_update_status_reason_code #=> String, one of "EniLimitExceeded", "InsufficientRolePermissions", "InvalidConfiguration", "InternalError", "SubnetOutOfIPAddresses", "InvalidSubnet", "InvalidSecurityGroup", "ImageDeleted", "ImageAccessDenied", "InvalidImage", "KMSKeyAccessDenied", "KMSKeyNotFound", "InvalidStateKMSKey", "DisabledKMSKey", "EFSIOError", "EFSMountConnectivityError", "EFSMountFailure", "EFSMountTimeout", "InvalidRuntime", "InvalidZipFileException", "FunctionError", "VcpuLimitExceeded", "CapacityProviderScalingLimitExceeded", "InsufficientCapacity", "EC2RequestLimitExceeded", "FunctionError.InitTimeout", "FunctionError.RuntimeInitError", "FunctionError.ExtensionInitError", "FunctionError.InvalidEntryPoint", "FunctionError.InvalidWorkingDirectory", "FunctionError.PermissionDenied", "FunctionError.TooManyExtensions", "FunctionError.InitResourceExhausted", "DisallowedByVpcEncryptionControl"
resp.file_system_configs #=> Array
resp.file_system_configs[0].arn #=> String
resp.file_system_configs[0].local_mount_path #=> String
resp.package_type #=> String, one of "Zip", "Image"
resp.image_config_response.image_config.entry_point #=> Array
resp.image_config_response.image_config.entry_point[0] #=> String
resp.image_config_response.image_config.command #=> Array
resp.image_config_response.image_config.command[0] #=> String
resp.image_config_response.image_config.working_directory #=> String
resp.image_config_response.error.error_code #=> String
resp.image_config_response.error.message #=> String
resp.signing_profile_version_arn #=> String
resp.signing_job_arn #=> String
resp.architectures #=> Array
resp.architectures[0] #=> String, one of "x86_64", "arm64"
resp.ephemeral_storage.size #=> Integer
resp.snap_start.apply_on #=> String, one of "PublishedVersions", "None"
resp.snap_start.optimization_status #=> String, one of "On", "Off"
resp.runtime_version_config.runtime_version_arn #=> String
resp.runtime_version_config.error.error_code #=> String
resp.runtime_version_config.error.message #=> String
resp.logging_config.log_format #=> String, one of "JSON", "Text"
resp.logging_config.application_log_level #=> String, one of "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"
resp.logging_config.system_log_level #=> String, one of "DEBUG", "INFO", "WARN"
resp.logging_config.log_group #=> String
resp.capacity_provider_config.lambda_managed_instances_capacity_provider_config.capacity_provider_arn #=> String
resp.capacity_provider_config.lambda_managed_instances_capacity_provider_config.per_execution_environment_max_concurrency #=> Integer
resp.capacity_provider_config.lambda_managed_instances_capacity_provider_config.execution_environment_memory_gi_b_per_v_cpu #=> Float
resp.config_sha_256 #=> String
resp.durable_config.retention_period_in_days #=> Integer
resp.durable_config.execution_timeout #=> Integer
resp.tenancy_config.tenant_isolation_mode #=> String, one of "PER_TENANT"
Options Hash (params):
-
:function_name
(required, String)
—
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
(String)
—
The Amazon Resource Name (ARN) of the function’s execution role.
-
:handler
(String)
—
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].
[1]: docs.aws.amazon.com/lambda/latest/dg/foundation-progmodel.html
-
:description
(String)
—
A description of the function.
-
:timeout
(Integer)
—
The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds. The maximum allowed value is 900 seconds. For more information, see [Lambda execution environment].
[1]: docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
-
:memory_size
(Integer)
—
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.
[1]: docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console
-
:vpc_config
(Types::VpcConfig)
—
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].
[1]: docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html
-
:environment
(Types::Environment)
—
Environment variables that are accessible from function code during execution.
-
:runtime
(String)
—
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].
[1]: docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html [2]: docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtime-deprecation-levels [3]: docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported
-
:dead_letter_config
(Types::DeadLetterConfig)
—
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].
[1]: docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq
-
:kms_key_arn
(String)
—
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].
[1]: docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption [2]: docs.aws.amazon.com/lambda/latest/dg/snapstart-security.html [3]: docs.aws.amazon.com/lambda/latest/dg/encrypt-zip-package.html#enable-zip-custom-encryption [4]: docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-lifecycle [5]: docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-owned-cmk [6]: docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk
-
-
:tracing_config
(Types::TracingConfig)
—
Set ‘Mode` to `Active` to sample and trace a subset of incoming requests with [X-Ray].
[1]: docs.aws.amazon.com/lambda/latest/dg/services-xray.html
-
:revision_id
(String)
—
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
(Array<String>)
—
A list of [function layers] to add to the function’s execution environment. Specify each layer by its ARN, including the version.
[1]: docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
-
:file_system_configs
(Array<Types::FileSystemConfig>)
—
Connection settings for an Amazon EFS file system.
-
:image_config
(Types::ImageConfig)
—
- Container image configuration values][1
-
that override the values in
the container image Docker file.
[1]: docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-parms
-
:ephemeral_storage
(Types::EphemeralStorage)
—
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
(Types::SnapStart)
—
The function’s [SnapStart] setting.
-
:logging_config
(Types::LoggingConfig)
—
The function’s Amazon CloudWatch Logs configuration settings.
-
:capacity_provider_config
(Types::CapacityProviderConfig)
—
Configuration for the capacity provider that manages compute resources for Lambda functions.
-
:durable_config
(Types::DurableConfig)
—
Configuration settings for durable functions. Allows updating execution timeout and retention period for functions with durability enabled.
See Also:
9462 9463 9464 9465 |
# File 'lib/aws-sdk-lambda/client.rb', line 9462 def update_function_configuration(params = {}, options = {}) req = build_request(:update_function_configuration, params) req.send_request(options) end |