Docker container for Yandex Cloud infrastructure management with Terraform
This Docker container provides a ready-to-use environment for working with Yandex Cloud infrastructure using Terraform.
- Docker installed on your system
- Yandex Cloud account with appropriate permissions
- OAuth token for Yandex Cloud API access
docker build -t yandex-terraform .Create a directory for your Terraform configuration:
mkdir my-terraform-project
cd my-terraform-project| Variable | Description | Required |
|---|---|---|
YC_TOKEN |
Yandex Cloud OAuth token | Yes |
YC_CLOUD_ID |
Yandex Cloud ID | No |
YC_FOLDER_ID |
Yandex Cloud Folder ID | No |
YC_ZONE |
Default zone (default: ru-central1-a) | No |
docker run -it --rm \
-e YC_TOKEN=your_oauth_token_here \
-e YC_CLOUD_ID=your_cloud_id_here \
-e YC_FOLDER_ID=your_folder_id_here \
-v $(pwd):/app \
yandex-terraform [command]# Initialize Terraform
docker run -it --rm \
-e YC_TOKEN=your_token \
-e YC_CLOUD_ID=your_cloud_id \
-e YC_FOLDER_ID=your_folder_id \
-v $(pwd):/app \
yandex-terraform init
# Plan infrastructure changes
docker run -it --rm \
-e YC_TOKEN=your_token \
-e YC_CLOUD_ID=your_cloud_id \
-e YC_FOLDER_ID=your_folder_id \
-v $(pwd):/app \
yandex-terraform plan
# Apply changes
docker run -it --rm \
-e YC_TOKEN=your_token \
-e YC_CLOUD_ID=your_cloud_id \
-e YC_FOLDER_ID=your_folder_id \
-v $(pwd):/app \
yandex-terraform apply
# Destroy infrastructure
docker run -it --rm \
-e YC_TOKEN=your_token \
-e YC_CLOUD_ID=your_cloud_id \
-e YC_FOLDER_ID=your_folder_id \
-v $(pwd):/app \
yandex-terraform destroyMount your local directory to /app in the container to persist Terraform state and configuration:
-v $(pwd):/app- "YC_TOKEN must be set" error: Ensure you pass the YC_TOKEN environment variable
- Permission errors: Check that your token has sufficient permissions in Yandex Cloud
- Network issues: Verify you can access Yandex Cloud APIs from your network
Run container with debug output:
docker run -it --rm \
-e YC_TOKEN=your_token \
-v $(pwd):/app \
yandex-terraform plan -verboseAdd to your ~/.bashrc or ~/.zshrc:
alias yterraform='docker run -it --rm -e YC_TOKEN=$YC_TOKEN -e YC_CLOUD_ID=$YC_CLOUD_ID -e YC_FOLDER_ID=$YC_FOLDER_ID -v $(pwd):/app yandex-terraform'Then use:
yterraform planCreate docker-compose.yml:
version: "3.8"
services:
yc-terraform:
image: yandex-terraform
environment:
- YC_TOKEN=${YC_TOKEN}
- YC_CLOUD_ID=${YC_CLOUD_ID}
- YC_FOLDER_ID=${YC_FOLDER_ID}
volumes:
- .:/app
working_dir: /appUse with:
docker-compose run --rm yc-terraform planFor Yandex Cloud specific issues, refer to:
For Docker issues, refer to Docker documentation and ensure your Docker installation is up to date.