Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
/ yc-remote-dev Public archive

Terraform config for remote dev environment at Yandex Cloud

License

Notifications You must be signed in to change notification settings

MrRTi/yc-remote-dev

Repository files navigation

Terraform config for remote dev environment at Yandex Cloud

Before you start


Prepare to setup

  • Copy .env.example to .env and fill or change variables

  • Copy secrets.env.example to secrets.env and fill or change variables

  • Copy remote/terraform.tfvars.example to remote/terraform.tfvars and fill or change variables

If you need to setup dns settings

  • Setup dns/domain variable in remote/terraform.tfvars

Use this command to find os_image_id for your needs

    yc compute image list --folder-id standard-images
  • Copy yc-remote-dev/remote/dns_records/cname_records.json.example to yc-remote-dev/remote/dns_records/cname_records.json and fill with required cname records

  • Copy yc-remote-dev/remote/dns_records/txt_records.json.example to yc-remote-dev/remote/dns_records/txt_records.json and fill with required txt records


Setup

  1. Build docker container

     $ make build
    
  2. Run docker container

     $ make infra
    
  3. Create SSH keys for root user at remote which will be created

     $ make generate_ssh
    
  4. Create remote in Yandex cloud

     $ cd remote
     $ t init
     $ t apply
    
  5. Confirm changes shown in plan


Your ssh key will be stored in terraform.tfstate and terraform.tfstate.backup files as plain text


Usage outside container

  1. To get remote info use:

     $ make dc_vm_info
    
  2. To get remote IP address use:

     $ make dc_vm_ip
    
  3. To start remote use:

     $ make dc_vm_start
    
  4. To stop remote use:

     $ make dc_vm_stop
    
  5. To connect by ssh use:

     $ eval $(make dc_ssh_vm)
    

Usage inside container

  1. If you don't run container with make infra setup yandex CLI with

     $ make yc_init
    
  2. To get remote info use:

     $ make vm_info
    
  3. To get remote IP address use:

     $ make vm_ip
    
  4. To start remote use:

     $ make vm_start
    
  5. To stop remote use:

     $ make vm_stop
    
  6. To connect by ssh use:

     $ eval $(make ssh_vm)
    

Additional info