-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-box.tf
61 lines (53 loc) · 1.11 KB
/
create-box.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
terraform {
required_providers {
linode = {
source = "linode/linode"
}
random = {
source = "hashicorp/random"
version = "3.1.0"
}
}
}
provider "random" {
# Configuration options
}
provider "linode" {
# Configuration options
}
resource "random_password" "password" {
length = 16
special = true
override_special = "_%@"
}
variable "box_name" {
type = string
description = "the name of the instance to be created"
default = "pair-box"
}
variable "public_ssh_key" {
type = string
description = "Your PUBLIC SSH key"
}
data "linode_images" "base_images" {
filter {
name = "label"
values = ["pair-box"]
}
filter {
name = "is_public"
values = ["false"]
}
latest = true
}
resource "linode_instance" "pair_box" {
label = "pair_box"
image = data.linode_images.base_images.images[0].id
region = "eu-west"
type = "g6-nanode-1"
authorized_keys = [ var.public_ssh_key ] # for root access
root_pass = random_password.password.result
}
output "box_ip" {
value = linode_instance.pair_box.ip_address
}