Creating a VM and accessing it
You can create a VM (Virtual Machine) and access it via SSH (Secure Shell) using Terraform.
Permissions
info
This action requires the following IAM (Identity and Access Management) permissions:
- compute.vpc.create
- compute.subnet.create
- compute.keypair.create
- compute.vm.create
- compute.publicIp.create
- compute.internetGateway.create
- compute.routeTable.create
- compute.securityGroup.create
Before you begin
info
Prerequisites
Creating and deploying Numspot resources
To get started, first create the configuration file ↗.
You must then create the following resources:
- VPC (Virtual Private Cloud);
- subnet;
- key pair;
- VM;
- public IP (Internet Protocol);
- internet gateway;
- route table;
- security group.
Add the following blocks:
resource "numspot_vpc" "vpc" {
ip_range = "10.0.0.0/16"
}
resource "numspot_subnet" "subnet" {
vpc_id = numspot_vpc.vpc.id
ip_range = "10.0.0.0/24"
map_public_ip_on_launch = true
}
resource "numspot_keypair" "keypair" {
name = "keypair_terraform"
public_key = "<PUBLIC KEYPAIR>"
}
resource "numspot_vm" "vm" {
image_id = "<VM IMAGE>"
type = "<VM TYPE>"
subnet_id = numspot_subnet.subnet.id
keypair_name = numspot_keypair.keypair.name
security_group_ids = [numspot_security_group.security-group.id]
}
resource "numspot_public_ip" "public-ip" {
vm_id = numspot_vm.vm.id
}
resource "numspot_internet_gateway" "internet-gateway" {
vpc_id = numspot_vpc.vpc.id
}
resource "numspot_route_table" "route-table" {
vpc_id = numspot_vpc.vpc.id
subnet_id = numspot_subnet.subnet.id
routes = [{
destination_ip_range = "0.0.0.0/0"
gateway_id = numspot_internet_gateway.internet-gateway.id
}]
}
resource "numspot_security_group" "security-group" {
vpc_id = numspot_vpc.vpc.id
name = "security group name"
description = "security group description"
inbound_rules = [{
from_port_range = 22
to_port_range = 22
ip_protocol = "tcp"
ip_ranges = ["0.0.0.0/0"]
}]
}
Your configuration is now ready to be deployed on the Numspot infrastructure ↗.