Created
July 31, 2019 11:57
-
-
Save acsrujan/c13d62676c14cefe2c704d913b59bcb0 to your computer and use it in GitHub Desktop.
Creates mysql RDS database using terraform. Needs development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_security_group" "mydatabase_sg" { | |
name = "mydatabase_sg" | |
description = "Allows services to talk to mydatabase mysql" | |
vpc_id = "vpc-xxxx" | |
ingress { | |
from_port = 3306 | |
to_port = 3306 | |
protocol = "TCP" | |
self = true | |
} | |
egress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} | |
module "dbmydatabase" { | |
source = "terraform-aws-modules/rds/aws" | |
version = "~> 2.0" | |
identifier = "mydatabase" | |
engine = "mysql" | |
engine_version = "5.7.25" | |
instance_class = "db.t2.small" | |
allocated_storage = 10 | |
name = "mydatabase" | |
username = "jesus" | |
password = "some_strong_password" | |
port = "3306" | |
vpc_security_group_ids = ["${aws_security_group.maxmind.id}"] | |
maintenance_window = "Mon:00:00-Mon:03:00" | |
backup_window = "03:00-06:00" | |
tags = { | |
Team = "some_application_team" | |
Environment = "production" | |
} | |
storage_encrypted = true | |
multi_az = true | |
# DB Subnet IDs | |
subnet_ids = ["subnet-xxxx", "subnet-xxxx", "subnet-xxxx"] | |
# Snapshot name upon DB deletion | |
final_snapshot_identifier = "mydatabase" | |
major_engine_version = "5.7" | |
family = "mysql5.7" | |
parameters = [ | |
{ | |
name = "character_set_client" | |
value = "utf8" | |
}, | |
{ | |
name = "character_set_server" | |
value = "utf8" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment