-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
76 lines (60 loc) · 1.75 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
local = {
source = "hashicorp/local"
version = "2.1.0"
}
}
}
provider "local" {
# Configuration options
}
provider "digitalocean" {
token = var.DO_token
}
provider "aws" {
region = "us-west-2"
access_key = var.my-access-key
secret_key = var.my-secret-key
}
resource "digitalocean_ssh_key" "my_key" {
name = "DOMYKEY"
public_key = var.my_DO_rsa
}
data "digitalocean_ssh_key" "rebrain_key" {
name = "REBRAIN.SSH.PUB.KEY"
}
resource "digitalocean_droplet" "ksumag" {
image = "ubuntu-18-04-x64"
name = "ksumag"
region = "fra1"
size = "s-1vcpu-1gb"
tags = ["devops", "dymon_ksu_at_gmail_com"]
ssh_keys = [digitalocean_ssh_key.my_key.fingerprint,data.digitalocean_ssh_key.rebrain_key.id ]
}
data "aws_route53_zone" "primary" {
name = "devops.rebrain.srwx.net"
}
resource "aws_route53_record" "myrecord" {
zone_id = data.aws_route53_zone.primary.zone_id
name = "${var.login_rebrain}.${data.aws_route53_zone.primary.name}"
type = "A"
ttl = "300"
records = [digitalocean_droplet.ksumag.ipv4_address]
}
resource "local_file" "inventory_1" {
content = templatefile("${path.module}/inventory.tpl", {
access_key = var.my_private,
ip = digitalocean_droplet.ksumag.ipv4_address,
name = aws_route53_record.myrecord.name
})
filename = "${path.module}/inventory_1.yml"
}