Search code examples
amazon-web-servicesterraformterraform-provider-awsamazon-aurora

Create AWS Aurora Database Schema from terraform


I am creating cluster instances aws_rds_cluster_instance (main.tf). Can I create schema from a file by using terraform.

  resource "aws_rds_cluster_instance" "default" {
  count                         = var.replica_count
  identifier                    = "${var.region}-${var.project}-${var.env}- 
 aurora-${count.index}"
  cluster_identifier            = aws_rds_cluster.default.id
  instance_class                = var.instance_class
  engine                        = aws_rds_cluster.default.engine
  engine_version                = aws_rds_cluster.default.engine_version
  db_parameter_group_name       = aws_db_parameter_group.this.name
  preferred_maintenance_window  = "sun:02:00-sun:04:00"
  auto_minor_version_upgrade    = var.auto_minor_version_upgrade
  performance_insights_enabled  = var.performance_insights_enabled

Solution

  • You can't do that with aws provider. However you could run local-exec which would call or execute a script that would create all the datatbases and tables that you need in your new aurora cluster.