Skip to content

darzanebor/terraform-yandex-compute-instance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yandex.Cloud Terraform Cloud Instance module

Example

module "compute_instance" {
  source          = "github.com/darzanebor/terraform-yandex-compute-instance.git"
  name            = "my-vm"
  zone            = "ru-central1-a"
  platform_id     = "standard-v1"
  vpc_subnet_name = "ru-central1-a"

  vpc_security_groups = ["sg-default"]
  create_default_security_group = true

  ipv4_private_address = "10.10.10.10"
  nat_ip_address       = "1.0.0.1"

  username = "default"
  password = "hashed_password"
  ssh_key  = file("~/.ssh/id_rsa.pub")

  allow_stopping_for_update = true

  allocate_ipv4 = true
  allocate_ipv6 = false
  allocate_nat  = false

  resources = {
    cores  = 2
    memory = 4
    core_fraction = null
  }

  boot_disk = {
    name     = "boot-disk-my-vm"
    type     = "network-ssd"
    zone     = "ru-central1-a"
    image_id = "fd80s5atj1quloqfr00f"
    labels = {
      environment = "test"
    }
  }

  dns_record = {
    zone_name = "my-dns-zone"
    fqdn = "my-vm.my-dns-zone.com."
    ttl = "3600"
    ptr = true
  }

  nat_dns_record = {
    zone_name = "my-dns-zone"
    fqdn = "my-vm.my-dns-zone.com."
    ttl = "3600"
    ptr = true
  }

  ipv6_dns_record = {
    zone_name = "my-dns-zone"
    fqdn = "my-vm.my-dns-zone.com."
    ttl = "3600"
    ptr = true
  }

  default_security_group_ingress = [
    {
      protocol       = "TCP"
      description    = "Allow All ingress."
      v4_cidr_blocks = ["0.0.0.0/0"]
      port           = -1
    },
  ]
  default_security_group_egress = [
    {
      protocol       = "ANY"
      description    = "Allow All egress."
      v4_cidr_blocks = ["0.0.0.0/0"]
      from_port      = -1
      to_port        = -1
    },
  ]
}

Requirements

Name Version
yandex >= 0.13

Providers

Name Version
template n/a
yandex >= 0.13

Modules

No modules.

Resources

Name Type
yandex_compute_disk.boot resource
yandex_compute_instance.this resource
yandex_vpc_security_group.this resource
template_file.this data source
yandex_dns_zone.dns_zone data source
yandex_dns_zone.ipv6_dns_zone data source
yandex_dns_zone.nat_dns_zone data source
yandex_vpc_subnet.this data source

Inputs

Name Description Type Default Required
allocate_ipv4 (Optional) Allocate an IPv4 address for the interface. The default value is true. bool true no
allocate_ipv6 (Optional) If true, allocate an IPv6 address for the interface. The address will be automatically assigned from the specified subnet. bool false no
allocate_nat (Optional) Provide a public address, for instance, to access the internet over NAT. bool false no
allow_stopping_for_update (Optional) Custom user-data for compute instance. bool false no
boot_disk (Required) The boot disk for the instance. map {} no
create_default_security_group (Optional) - Create default security group. bool false no
default_security_group_egress (Optional) - A list of egress rules to create with default security group. list [] no
default_security_group_ingress (Optional) - A list of ingress rules to create with default security group. list [] no
dns_record (Optional) List of configurations for creating ipv4 DNS records. The structure is documented below. map {} no
ipv4_private_address (Optional) The private IP address to assign to the instance. If empty, the address will be automatically assigned from the specified subnet. any null no
ipv6_dns_record (Optional) List of configurations for creating ipv6 DNS records. The structure is documented below. map {} no
ipv6_private_address (Optional) The private IPv6 address to assign to the instance. If empty, the address will be automatically assigned from the specified subnet. any null no
name (Optional) Resource name. any null no
nat_dns_record (Optional) List of configurations for creating ipv4 NAT DNS records. The structure is documented below. map {} no
nat_public_ip_address (Optional) Provide a public address, for instance, to access the internet over NAT. any null no
password (Optional) Provide password for creation on instance with cloud-init for user. string "" no
platform_id (Optional) The type of virtual machine to create. The default is 'standard-v1'. any null no
resources (Required) Compute resources that are allocated for the instance. map {} no
ssh_key (Optional) Provide public ssh_key to assign to user on compute instance. string "" no
user_data (Optional) Custom user-data for compute instance. string "" no
user_groups (Optional) Provide groups to assign to user on compute instance. string "sudo" no
username (Optional) Provide username for creation on instance with cloud-init. string "" no
vpc_security_groups (Optional) - Assign security groups to instance. list [] no
vpc_subnet_name (Required) VPC subnet to place the instance. any n/a yes
zone (Optional) The availability zone where the virtual machine will be created. If it is not provided, the default provider folder is used. any null no

Outputs

Name Description
yandex_compute_disk_boot n/a
yandex_compute_instance n/a
yandex_vpc_security_group n/a