-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
46 lines (40 loc) · 1.01 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
provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_ssh_key" "default" {
name = "Default"
public_key = "${file(var.pub_key)}"
}
resource "digitalocean_droplet" "dev" {
image = "docker-18-04"
name = "dev"
region = "nyc3"
size = "1gb"
ipv6 = true
ssh_keys = [
"${digitalocean_ssh_key.default.fingerprint}"
]
connection {
user = "root"
type = "ssh"
private_key = "${file(var.pvt_key)}"
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"adduser --quiet --disabled-password --shell /bin/bash --home /home/kwngo --gecos \"User\" kwngo",
"echo \"kwngo:testpass\" | chpasswd && usermod -aG docker kwngo"
]
}
}
resource "digitalocean_domain" "default" {
name = "kareem.codes"
ip_address = "${digitalocean_droplet.dev.ipv4_address}"
}
resource "digitalocean_record" "CNAME-dev" {
domain = "${digitalocean_domain.default.name}"
type = "CNAME"
name = "dev"
value ="@"
}