I have created EC2 and My sql instance using below code and it executed successfully. what is the procedure if we need to create mysql database in a particular ec2 instance, if there are multiple running.I could see db-instance in aws console . Even though there is option available in console to create database, I need to perform through terraform code.
resource "aws_instance" "DB-Server"
{
ami = "ami-051f75c6"
instance_type = "t2.micro"
key_name="Key-pair
}
resource "aws_db_instance" "default"
{
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
name = "mydb"
username = "username"
password = "XXXX"
`enter code here`parameter_group_name = "default.mysql5.7"
}