-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.tf
82 lines (71 loc) · 2.28 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
provider "aws" {
region = "us-east-1"
}
variable "azs" {
type = "list"
default = [
"us-east-1a",
"us-east-1b",
"us-east-1c",
]
}
module "aurora" {
source = "../../"
name = "aurora-example-mysql"
engine = "aurora-mysql"
engine_version = "5.7.12"
subnet_ids = ["${module.vpc.database_subnets}"]
availability_zones = ["${var.azs}"]
vpc_id = "${module.vpc.vpc_id}"
replica_count = 1
instance_type = "db.t2.medium"
apply_immediately = true
skip_final_snapshot = true
db_parameter_group_name = "${aws_db_parameter_group.aurora_db_57_parameter_group.id}"
db_cluster_parameter_group_name = "${aws_rds_cluster_parameter_group.aurora_57_cluster_parameter_group.id}"
}
resource "aws_db_parameter_group" "aurora_db_57_parameter_group" {
name = "test-aurora-db-57-parameter-group"
family = "aurora-mysql5.7"
description = "test-aurora-db-57-parameter-group"
}
resource "aws_rds_cluster_parameter_group" "aurora_57_cluster_parameter_group" {
name = "test-aurora-57-cluster-parameter-group"
family = "aurora-mysql5.7"
description = "test-aurora-57-cluster-parameter-group"
}
resource "aws_security_group" "app_servers" {
name = "app-servers"
description = "For application servers"
vpc_id = "${module.vpc.vpc_id}"
}
resource "aws_security_group_rule" "allow_access" {
type = "ingress"
from_port = "${module.aurora.cluster_port}"
to_port = "${module.aurora.cluster_port}"
protocol = "tcp"
source_security_group_id = "${aws_security_group.app_servers.id}"
security_group_id = "${module.aurora.security_group_id}"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "1.46.0"
name = "example-mysql"
cidr = "10.0.0.0/16"
azs = ["${var.azs}"]
private_subnets = [
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/25",
]
public_subnets = [
"10.0.4.0/24",
"10.0.5.0/24",
"10.0.6.0/25",
]
database_subnets = [
"10.0.7.0/24",
"10.0.8.0/24",
"10.0.9.0/25",
]
}