> For the complete documentation index, see [llms.txt](https://book.konstantinsecurity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.konstantinsecurity.com/readme/architect/kubernetes/terraform-ci-security/yandex-terraform-scan.md).

# Yandex Terraform scan

<https://cloud.yandex.ru/docs/security/domains/secure-config#terraform>

[generate](https://gitlab.com/johnmkane/tech-recipe-book/-/blob/main/Book/Architect/Kubernetes/Terraform%20CI%20security/Yandex%20Terraform%20scan/Yandex%20Terraform%20scan/generate/README.md)

При развертывании ВМ рекомендуется:

* Подготовить образ ВМ, настройки системы в котором соответствуют вашей политике информационной безопасности. Создать образ можно с помощью Packer, см. раздел [Начало работы с Packer](https://cloud.yandex.ru/docs/tutorials/infrastructure-management/packer-quickstart).
* Использовать этот образ для создания ВМ или [группы ВМ](https://cloud.yandex.ru/docs/compute/concepts/instance-groups/).
* В информации о ВМ убедиться, что для создания диска использовался именно этот образ.

### [Terraform](https://cloud.yandex.ru/docs/security/domains/secure-config#terraform)

Terraform позволяет управлять облачной инфраструктурой с помощью файлов конфигураций. При изменении файлов Terraform автоматически определяет, какая часть вашей конфигурации уже развернута, что следует добавить или удалить. Подробнее в разделе [Начало работы с Terraform](https://cloud.yandex.ru/docs/tutorials/infrastructure-management/terraform-quickstart).

В файлах конфигураций Terraform не рекомендуется указывать приватную информацию: пароли, секреты, персональные данные, данные платежных систем и др. Вместо этого необходимо использовать сервисы для хранения и использования в конфигурации секретов, например: [HashiCorp Vault](https://cloud.yandex.ru/marketplace/products/yc/vault-yckms) из Yandex Cloud Marketplace или [Yandex Lockbox](https://cloud.yandex.ru/docs/lockbox/) (для передачи секретов в целевой объект без использования Terraform).

Если все же требуется указать приватную информацию в конфигурации, необходимо принять меры безопасности:

Указывать для приватной информации параметр sensitive = true, чтобы отключить ее вывод в консоль при выполнении команд `terraform plan`, `terraform apply`. Использовать terraform remote state. Рекомендуется загружать состояние Terraform в Yandex Object Storage (см. раздел [Загрузка состояний Terraform в Object Storage](https://cloud.yandex.ru/docs/tutorials/infrastructure-management/terraform-state-storage)), а также настроить блокировку конфигурации с помощью Yandex Managed Service for YDB для предотвращения одновременного редактирования администраторами (см. пример настройки). Использовать механизм передачи секретов в Terraform через env вместо plain text либо использовать встроенную возможность Yandex Key Management Service по [шифрованию данных в Terraform](https://cloud.yandex.ru/docs/kms/tutorials/terraform-secret) (с помощью отдельного файла с приватными данными) (подробнее о данной технике).

Об обеспечении безопасности Object Storage читайте ниже в подразделе [Object Storage](https://cloud.yandex.ru/docs/security/domains/secure-config#object-storage).

Важно

После развертывания конфигурации файл конфигурации с приватными данными можно удалить.

Проверяйте ваши Terraform-манифесты с помощью Checkov с поддержкой Yandex Cloud.

Пример: сканирование tf-файлов с помощью Checkov

Пример: хранение состояния Terraform в Object Storage


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.konstantinsecurity.com/readme/architect/kubernetes/terraform-ci-security/yandex-terraform-scan.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
