-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaurora.tf
57 lines (46 loc) · 2.13 KB
/
aurora.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
################################################################################
### RDS CLUSTER Instance
################################################################################
resource "aws_rds_cluster_instance" "cluster_magento" {
count = 1 # The amount of instances of your cluster
apply_immediately = false
identifier = "aurora-cluster-magento-${count.index}"
cluster_identifier = aws_rds_cluster.cluster_magento.id
instance_class = "db.t2.small" # @see https://aws.amazon.com/de/rds/instance-types/
auto_minor_version_upgrade = true
publicly_accessible = false
}
########################################################################
### RDS CLUSTER
### @see https://www.terraform.io/docs/providers/aws/r/rds_cluster.html
########################################################################
resource "aws_rds_cluster" "cluster_magento" {
skip_final_snapshot = false
final_snapshot_identifier = "magento-final-snap"
cluster_identifier = "aurora-cluster-magento"
database_name = "d${replace(lower(random_id.rds_database.b64), "-", "")}"
master_username = "u${replace(lower(random_id.rds_username.b64), "-", "")}"
master_password = "p${replace(lower(random_id.rds_password.b64), "-", "")}"
backup_retention_period = 14 # Days of how long a backup will be saved
preferred_backup_window = "00:00-02:00"
preferred_maintenance_window = "Mon:02:00-Mon:04:00"
port = 3306
apply_immediately = false
copy_tags_to_snapshot = true
tags = {
Terraform-Magento = "staging"
}
availability_zones = data.aws_availability_zones.all.names # ALL --> Multi AZ
vpc_security_group_ids = [
aws_security_group.rds.id,
]
}
resource "random_id" "rds_username" {
byte_length = 8 # random generated database username
}
resource "random_id" "rds_database" {
byte_length = 8 # random generated database name
}
resource "random_id" "rds_password" {
byte_length = 16 # random generated database password
}