Skip to content

Instantly share code, notes, and snippets.

@acsrujan
Created July 31, 2019 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acsrujan/c13d62676c14cefe2c704d913b59bcb0 to your computer and use it in GitHub Desktop.
Save acsrujan/c13d62676c14cefe2c704d913b59bcb0 to your computer and use it in GitHub Desktop.
Creates mysql RDS database using terraform. Needs development.
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