-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
111 lines (91 loc) · 2.33 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
variable "allowed_account_ids" {
type = list(string)
}
variable "default_tags" {
type = map(string)
}
variable "name" {
type = string
}
variable "engine" {
type = string
}
variable "engine_version" {
type = string
}
variable "database_name" {
type = string
}
variable "master_username" {
type = string
}
variable "master_password" {
type = string
}
variable "instance_class" {
type = string
}
variable "ec2_authorized_keys" {
type = list(string)
}
provider "aws" {
alias = "tokyo"
region = "ap-northeast-1"
allowed_account_ids = var.allowed_account_ids
default_tags {
tags = var.default_tags
}
}
provider "aws" {
alias = "osaka"
region = "ap-northeast-3"
allowed_account_ids = var.allowed_account_ids
default_tags {
tags = var.default_tags
}
}
resource "aws_rds_global_cluster" "main" {
global_cluster_identifier = var.name
engine = var.engine
engine_version = var.engine_version
database_name = var.database_name
deletion_protection = false
force_destroy = true
}
module "tokyo" {
providers = { aws = aws.tokyo }
source = "./region"
name = "${var.name}-tokyo"
engine = var.engine
engine_version = var.engine_version
master_username = var.master_username
master_password = var.master_password
database_name = var.database_name
instance_class = var.instance_class
instance_count = 1
ec2_authorized_keys = var.ec2_authorized_keys
global_cluster_identifier = aws_rds_global_cluster.main.id
}
module "osaka" {
providers = { aws = aws.osaka }
source = "./region"
name = "${var.name}-osaka"
engine = var.engine
engine_version = var.engine_version
master_username = null
master_password = null
database_name = null
instance_class = var.instance_class
instance_count = 1
ec2_authorized_keys = var.ec2_authorized_keys
global_cluster_identifier = aws_rds_global_cluster.main.id
depends_on = [
module.tokyo.rds_cluster,
]
}
output "tokyo" {
value = module.tokyo.output
}
output "osaka" {
value = module.osaka.output
}