Mounting an ephemeral disk to a function
Note
This feature is in the Preview stage. To get access, contact tech support
-
In the management console
, select the folder containing the function. -
Select Cloud Functions.
-
Select a function.
-
In the left-hand menu, select
Editor. -
Under Mounted ephemeral disk:
-
Click Add ephemeral disk.
-
Specify the following in the field:
- Mount point: Name of the mount point. Use this path to access the directory in which the ephemeral disk is mounted:
/function/storage/<mount_point>. - Disk size: Amount of memory you want to allocate for the ephemeral disk you are mounting.
- Mount point: Name of the mount point. Use this path to access the directory in which the ephemeral disk is mounted:
-
-
Click Save changes.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To mount an ephemeral disk to a function, run this command:
yc serverless function version create \
--function-name=<function_name> \
--runtime <runtime_environment> \
--entrypoint <entry_point> \
--memory <RAM_size> \
--execution-timeout <execution_timeout> \
--source-path <path_to_ZIP_archive> \
--service-account-id <service_account_ID> \
--mount type=ephemeral-disk,mount-point=<mount_point>,size=<disk_size>
Where:
--function-name: Function name.--runtime: Runtime environment.entrypoint: Entry point in the following format:<file_name_without_extension>.<listener_name>.--memory: Amount of RAM.--execution-timeout: Maximum running time of the function until timeout.--source-path: ZIP archive with the function code and required dependencies.--service-account-id: Service account ID.--mount: Ephemeral disk mounting parameters:type=ephemeral-disk: Type of the file system being mounted.mount-point: Name of the mount point. Use this path to access the directory the disk will be mounted to:/function/storage/<mount_point>.size: Ephemeral disk size in GB, e.g.,size=5GB.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To mount an ephemeral disk to a function:
-
Open the Terraform configuration file and add the
mountssection to the function description:resource "yandex_function" "ephemeral_storage_function" { name = "<function_name>" user_hash = "<function_hash>" runtime = "<runtime_environment>" entrypoint = "<entry_point>" memory = "<RAM_size>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" content { zip_filename = "<path_to_ZIP_archive>" } mounts { name = "<mount_point>" ephemeral_disk { size_gb = <disk_size> } } }Where:
mounts: Ephemeral disk mounting parameters:name: Name of the mount point. Use this path to access the directory the disk will be mounted to:/function/storage/<mount_point>.size_gb: Ephemeral disk size in GB, e.g.,size=5GB.
For more information about the
yandex_functionresource parameters, see this Terraform article. -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
You can check the function update and its settings using the management console
yc serverless function version get <function_version_ID>
To mount an ephemeral disk to a function, use the createVersion REST API method for the Function resource or the FunctionService/CreateVersion gRPC API call.