aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'infra/rds.tf')
-rw-r--r--infra/rds.tf58
1 files changed, 58 insertions, 0 deletions
diff --git a/infra/rds.tf b/infra/rds.tf
new file mode 100644
index 0000000..d9ba204
--- /dev/null
+++ b/infra/rds.tf
@@ -0,0 +1,58 @@
1resource "aws_db_parameter_group" "mastodon" {
2 name = var.name
3 family = var.rds_parameter_group
4}
5
6resource "aws_db_instance" "mastodon" {
7 identifier = var.name
8 instance_class = var.rds_instance_class
9 allocated_storage = var.rds_storage_size
10 engine = var.rds_engine
11 engine_version = var.rds_engine_version
12 username = var.rds_username
13 password = random_password.rds_password.result
14 port = var.rds_port
15 db_subnet_group_name = aws_db_subnet_group.mastodon.name
16 vpc_security_group_ids = [aws_security_group.rds.id]
17 parameter_group_name = aws_db_parameter_group.mastodon.name
18 publicly_accessible = true
19 skip_final_snapshot = true
20
21 backup_retention_period = 7
22 performance_insights_enabled = true
23}
24
25resource "random_password" "rds_password" {
26 length = 16
27 special = false
28}
29
30resource "aws_ssm_parameter" "rds_host" {
31 name = "/${var.name}/rds/host"
32 type = "String"
33 value = aws_db_instance.mastodon.address
34}
35
36resource "aws_ssm_parameter" "rds_port" {
37 name = "/${var.name}/rds/port"
38 type = "String"
39 value = aws_db_instance.mastodon.port
40}
41
42resource "aws_ssm_parameter" "mastodon_db_name" {
43 name = "/${local.name}/rds/name"
44 type = "String"
45 value = aws_db_instance.mastodon.db_name
46}
47
48resource "aws_ssm_parameter" "mastodon_db_user" {
49 name = "/${local.name}/rds/username"
50 type = "String"
51 value = aws_db_instance.mastodon.username
52}
53
54resource "aws_ssm_parameter" "mastodon_db_password" {
55 name = "/${local.name}/rds/password"
56 type = "SecureString"
57 value = random_password.rds_password.result
58}
Powered by cgit v1.2.3 (git 2.41.0)