1
votes

I think I am stuck on the error of the Terraform configuration for AWS RDS Aurora. I am following https://www.terraform.io/docs/providers/aws/r/db_instance.html but I still got error on Error creating DB Instance: InvalidParameterCombination: Standalone DB Instances are not supported for the specified engine

My question is what is the recommended way to create the terraform configuration from scratch?

This is my terraform config file

resource "aws_db_instance" "test" {
    identifier                = "test"
    allocated_storage         = 1
    storage_type              = "aurora"
    engine                    = "aurora"
    engine_version            = "5.6.10a"
    instance_class            = "db.t2.small"
    name                      = "testdb"
    username                  = "testadmin"
    password                  = "xxxxx"
    port                      = 3306
    publicly_accessible       = false
    availability_zone         = "us-east-2a"
    security_group_names      = []
    vpc_security_group_ids    = ["sg-xxxxx"]
    db_subnet_group_name      = "default-vpc-xxxxx"
    parameter_group_name      = "default.aurora5.6"
    multi_az                  = false
    backup_retention_period   = 1
    #backup_window             = "08:48-09:18"
    #maintenance_window        = "sun:08:56-sun:09:26"
    final_snapshot_identifier = "test-final"
}
1

1 Answers

2
votes

AWS' Aurora uses a different API to the normal database instance calls that standard MySQL, Postgresql, etc use and instead uses the database cluster calls.

In Terraform this maps to the aws_rds_cluster and aws_rds_cluster_instance resources instead of the aws_db_instance resource.

As such you need to use something like this:

resource "aws_rds_cluster_instance" "cluster_instances" {
  count              = 1
  identifier         = "aurora-cluster-demo-${count.index}"
  cluster_identifier = "${aws_rds_cluster.default.id}"
  instance_class     = "db.t2.small"
}

resource "aws_rds_cluster" "default" {
  cluster_identifier = "aurora-cluster-demo"
  availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
  database_name      = "mydb"
  master_username    = "foo"
  master_password    = "barbut8chars"
}