-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.tf
71 lines (60 loc) · 1.6 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
provider "aws" {
region = "${var.region}"
}
terraform {
backend "s3" {}
}
data "terraform_remote_state" "vpc" {
backend = "s3"
config = "${var.vpc_state_config}"
}
resource "aws_security_group" "default" {
vpc_id = "${data.terraform_remote_state.vpc.vpc_id}"
name = "${format("%s-sg", var.name)}"
description = "${format("Security Group for %s", var.name)}"
ingress {
protocol = "tcp"
from_port = 3306
to_port = 3306
cidr_blocks = ["${data.terraform_remote_state.vpc.private_subnets_cidr_blocks}"]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_db_subnet_group" "default" {
name = "${var.name}"
description = "${var.name}"
subnet_ids = ["${data.terraform_remote_state.vpc.private_subnets}"]
tags {
Name = "${var.name}"
Environment = "${var.environment}"
}
}
resource "aws_rds_cluster" "default" {
cluster_identifier = "${var.name}"
vpc_security_group_ids = ["${aws_security_group.default.id}"]
db_subnet_group_name = "${aws_db_subnet_group.default.name}"
engine_mode = "serverless"
master_username = "${var.username}"
master_password = "${var.password}"
backup_retention_period = 7
skip_final_snapshot = false
scaling_configuration {
auto_pause = true
max_capacity = 2
min_capacity = 2
seconds_until_auto_pause = 300
}
lifecycle {
ignore_changes = [
"engine_version",
]
}
}