-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
69 lines (55 loc) · 1.85 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
provider "tencentcloud" {
region = "ap-guangzhou"
}
module "vpc" {
source = "./modules/vpc"
vpc_name = var.vpc_name
vpc_cidr_block = var.vpc_cidr_block
subnet_cidr_block = var.subnet_cidr_block
subnet_name = var.subnet_name
availability_zone = var.availability_zone
}
module "securityGroup-cvm" {
source = "./modules/securityGroups"
name = var.sg_description
description = var.sg_description
# ingress-action = "ACCEPT"
# egress-action = "ACCEPT"
}
module "cvm-instance" {
source = "./modules/cvm"
depends_on = [module.vpc, module.securityGroup-cvm]
instance_name = var.instance_name
availability_zone = var.availability_zone
image_id = var.image_id
instance_type = var.instance_type
vpc_id = module.vpc.vpc_id
subnet_id = module.vpc.subnet_id
allocate_public_ip = var.allocate_public_ip
password = var.password
security_group_ids = [module.securityGroup-cvm.security_group_id]
tags = var.tags
}
module "securityGroup-mysql" {
source = "./modules/securityGroups"
name = var.sg_description
description = var.sg_description
ingress-action = "ACCEPT"
ingress-port = "3306"
ingress-cidr_block = module.cvm-instance.private_ip
ingress-protocol = "TCP"
egress-action = "ACCEPT"
egress-port = "3306"
egress-cidr_block = module.cvm-instance.private_ip
egress-protocol = "TCP"
}
module "mysql-instance" {
source = "./modules/mysql"
depends_on = [module.vpc, module.securityGroup-mysql]
create_mysql_instance = true
instance_name = var.mysql_instance_name
root_password = var.mysql_instance_password
security_groups = [module.securityGroup-mysql.security_group_id]
vpc_id = module.vpc.vpc_id
subnet_id = module.vpc.subnet_id
}