InvalidParameterCombination error when creating RDS instance in Terraform

A few days ago I was tasked with provisioning infrastructure for an application using Terraform. Until recently my experience with RDS instances had been creating, copying and sharing snapshots, and referencing the correct snapshot in the resource block of the Terraform script. On this occasion, however, I needed to create a database instance without using a snapshot.

The Terraform resource block for creating an RDS instance looked like this:

When running terraform apply in order to create an RDS instance, the following message appeared:

Error creating DB Instance: InvalidParameterCombination: RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.small, Engine=sql, EngineVersion= 15.00.4073.23

It turns out that if the engine_version attribute is not specified,the default one will be the most recent – in this case Microsoft SQL Server 2019 (15.00.4073.23). However, looking at the DB instance classes supported for this version of the SQL Server 2019 on this AWS page, you can see that db.t2.small instance class is not supported. The fix in this case is to specify the engine version or change the DB instance class. In my case the decision was to up the instance class to db.t3.small, and the RDS instance was successfully created.