Configuring metadata service parameters for a container
You can configure metadata service parameters when creating a container revision.
Available options:
-
awsV1HttpEndpoint
: Provides access to metadata using the AWS format (IMDSv1). It can be eitherenabled
ordisabled
. If set todisabled
, the metadata request will fail with error404 Not Found
. The default value isenabled
.Note
The
awsV1HttpEndpoint
parameter isenabled
by default, but we recommend disabling it. The IMDSv1 format comes with a number of security vulnerabilities. Its most severe flaw is the high risk of attacks, such as SSRF . For more information, see the AWS official blog . -
gceHttpEndpoint
: Provides access to metadata using the Google Compute Engine format. It can be eitherenabled
ordisabled
. If set todisabled
, the metadata request will fail with error404 Not Found
. The default value isenabled
.
- In the management console
, select the folder with your container. - Select Serverless Containers.
- Select the container.
- Navigate to the Editor tab.
- Expand the Metadata service parameters section.
- Configure metadata service parameters for the container:
Access metadata using the Google Compute Engine format
andAccess metadata using the AWS format (IMDSv1)
. - Click Create revision.
To configure metadata service parameters for a container, run this command:
yc serverless container revision deploy \
--container-id <container_ID> \
--image <Docker_image_URL> \
--service-account-id <service_account_ID>
--metadata-options <option>=<enable_or_disabled>
Where:
--container-id
: Container ID. To find out the ID, get a list of containers.--image
: Yandex Container Registry Docker image URL.--service-account-id
: ID of the service account with permissions to download a Docker image.--metadata-options
: Settings for the metadata service parameters, e.g.,aws-v1-http-endpoint=disabled
.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To configure metadata service parameters for a container:
-
Open the Terraform configuration file and add the
metadata_options
section to the container description:resource "yandex_serverless_container" "metadata_container" { name = "<container_name>" memory = "<RAM_size>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" content { zip_filename = "<path_to_ZIP_archive>" } image { url = <container_image_path> } metadata_options { metadata_options.0.gce_http_endpoint = "0_or_1_or_2" metadata_options.0.aws_v1_http_endpoint = "0_or_1_or_2" } }
Where:
metadata_options
: Settings for the metadata service parameters, e.g.,metadata_options.0.gce_http_endpoint = "1"
. Specify the following:0
if you want to keep the default value.1
to enable the parameter.2
to disable the parameter.
For more information about the
yandex_serverless_container
resource parameters, see this Terraform article . -
Apply the changes:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
-
You can check that the container and its settings have changed using the management console
yc serverless container revision get <container_revision_ID>
To conigure metadata service parameters for a container, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.