O'Reilly logo

Effective DevOps with AWS - Second Edition by Nathaniel Felsen, Giuseppe Borgese, Yogesh Raheja

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving the database to the RDS

To create the MySQL database, we can use a public module that is available in the official repository found here: https://registry.terraform.io/modules/terraform-aws-modules/rds/aws/1.21.0.

In the following code, I will simplify the original example slightly and add a security group as follows. Refer to the main.tf file:

resource "aws_security_group" "rds" {  name = "allow_from_my_vpc"  description = "Allow from my vpc"  vpc_id = "${var.my_default_vpcid}"  ingress {    from_port = 3306    to_port = 3306    protocol = "tcp"    cidr_blocks = ["172.31.0.0/16"]  }}module "db" {  source = "terraform-aws-modules/rds/aws"  identifier = "demodb"  engine = "mysql"  engine_version = "5.7.19"  instance_class = "db.t2.micro" allocated_storage ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required