-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
98 lines (84 loc) · 2.38 KB
/
Copy pathmain.tf
File metadata and controls
98 lines (84 loc) · 2.38 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
terraform {
cloud {
organization = "your_organization" # Replace with your Terraform Cloud organization
workspaces {
name = "your_workspace" # Replace with your workspace name
}
}
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
provider "digitalocean" {
token = var.digitalocean_token
}
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
# Odoo Server Module Configuration
module "odoo_server" {
source = "./modules/odoo"
# Providers
providers = {
digitalocean = digitalocean
cloudflare = cloudflare
}
# Variables passed to the module
specific_ip = var.specific_ip
project_id = var.project_id
ssh_private_key_path = var.ssh_private_key_path
setup_profile = var.setup_profile
droplet_name = var.droplet_name
domain_name = var.domain_name
root_domain = var.root_domain
subdomain_name = var.subdomain_name
ssh_key_id = var.ssh_key_id
ssh_public_key = var.ssh_public_key
non_root_user = var.non_root_user
non_root_password = var.non_root_password
db_host = var.db_host
root_password = var.root_password
admin_passwd = var.admin_passwd
db_user = var.db_user
db_password = var.db_password
cloudflare_zone_id = var.cloudflare_zone_id
dns_ttl = var.dns_ttl
region = local.region
size = local.droplet_size
swap_size = local.swap_size
}
# Cloudflare DNS Records for Root Domain
resource "cloudflare_record" "root_record" {
zone_id = var.cloudflare_zone_id
name = var.root_domain
type = "A"
value = module.odoo_server.odoo_ip
ttl = var.dns_ttl
depends_on = [module.odoo_server]
}
# Cloudflare DNS Records for Subdomain
resource "cloudflare_record" "subdomain_record" {
zone_id = var.cloudflare_zone_id
name = var.subdomain_name
type = "A"
value = module.odoo_server.odoo_ip
ttl = var.dns_ttl
depends_on = [module.odoo_server]
}
# Outputs
output "odoo_ip" {
value = module.odoo_server.odoo_ip
}
output "root_domain_record" {
value = cloudflare_record.root_record.name
}
output "subdomain_record" {
value = cloudflare_record.subdomain_record.name
}