Configuring parameters of the VM metadata service
You can configure parameters of the VM metadata service when creating or updating the VM.
To configure metadata service parameters for a VM:
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.
-
View the description of the CLI command for updating VM parameters:
yc compute instance update --help -
Get a list of VMs in the default folder:
yc compute instance list -
Select
IDorNAMEof the VM you need. -
Define the metadata service settings:
yc compute instance update <VM_ID> \ --metadata-options gce-http-endpoint=enabledWhere
--metadata-optionsis the parameter defining the settings of the VM metadata service. The possible values are:gce-http-endpoint: Allows you to access metadata using the Google Compute Engine format. It can be eitherenabledordisabled.gce-http-token: Allows you to get the service account IAM token for the VM using Google Compute Engine metadata. It can be eitherenabledordisabled.
For more information, see VM instance metadata service parameters.
To configure parameters of the VM metadata service when creating the VM, use the --metadata-options parameter in the yc compute instance create command in the same way.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
-
Open the Terraform configuration file and specify the
metadata_optionsparameter in the VM description:... resource "yandex_compute_instance" "test-vm" { ... metadata_options { gce_http_endpoint = 0 gce_http_token = 0 } ... } ...Where:
-
yandex_compute_instance: VM description:metadata_options: Metadata parameters:gce_http_endpoint: Allows you to access metadata using the Google Compute Engine format. Possible values:0,1forenabledand2fordisabled.gce_http_token: Allows you to get the service account IAM token for the VM using Google Compute Engine metadata. Possible values:0,1forenabledand2fordisabled.
For more information, see VM instance metadata service parameters.
For more information about the
yandex_compute_instanceresource parameters in Terraform, see this TF provider article. -
-
Create the resources:
-
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.
All the resources you need will then be created in the specified folder with the settings you defined. You can check the new resources and their settings using the management console
or this CLI command:yc compute instance get <VM_name> -
When creating a VM, use the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.
When updating a VM, use the update REST API method for the Instance resource or the InstanceService/Update gRPC API call.