-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.tf
47 lines (40 loc) · 1.04 KB
/
main.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
variable "LINODE_KEY" {
type = string
description = "Access key for linode to launch a new server"
}
variable "LINODE_DOMAIN_ID" {
type = string
description = "Domain ID for linode to point to server"
}
variable "SSH_PUBLIC_KEY" {
type = string
description = "Public key to ssh into server"
}
variable "JOB_ID" {
type = string
description = "Job ID"
}
output "ip" {
value = linode_instance.ion-test.ip_address
}
provider "linode" {
token = var.LINODE_KEY
}
# Definition ssh key from variable
resource "linode_sshkey" "user" {
label = "ion-test-ssh-key-${var.JOB_ID}"
ssh_key = var.SSH_PUBLIC_KEY
}
resource "linode_instance" "ion-test" {
label = "ion-test-${var.JOB_ID}"
image = "linode/ubuntu20.04"
region = "us-west"
type = "g6-standard-4"
authorized_keys = ["${linode_sshkey.user.ssh_key}"]
}
resource "linode_domain_record" "ion-domain" {
domain_id = var.LINODE_DOMAIN_ID
name = "job-${var.JOB_ID}"
record_type = "A"
target = linode_instance.ion-test.ip_address
}