- Newest
- Most votes
- Most comments
Hi Daigo Tsuchiya,
Please go through the below steps I hope it will help solve your issue.
1. Change the Instance Class
The db.t2.micro instance type may not support the MySQL version you're trying to use. You can switch to a different instance class like db.t3.micro, which is often compatible with newer versions of MySQL.
Update your aws_db_instance resource to use db.t3.micro:
resource "aws_db_instance" "example" {
identifier_prefix = "terraform-up-and-running"
engine = "mysql"
engine_version = "8.0.35" # Ensure this is the correct version for your instance class
allocated_storage = 10
instance_class = "db.t3.micro" # Updated instance class
skip_final_snapshot = true
db_name = var.db_name
username = var.db_username
password = var.db_password
}
2. Specify the Engine Version (Optional)
Although it's not always necessary, specifying the engine version explicitly can help avoid issues. If you continue to face issues, you might also want to check which versions are compatible with the db.t3.micro instance class in the AWS RDS Documentation.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html
3. Review Other Parameters
Ensure that all other parameters in your aws_db_instance resource are correct. For example, you might want to specify backup_retention_period or parameter_group_name based on your requirements.
Full Example with Modifications Here’s how your updated aws_db_instance resource might look:
resource "aws_db_instance" "example" {
identifier_prefix = "terraform-up-and-running"
engine = "mysql"
engine_version = "8.0.35" # Make sure this version is supported by the instance class
allocated_storage = 10
instance_class = "db.t3.micro" # Updated instance class
skip_final_snapshot = true
db_name = var.db_name
username = var.db_username
password = var.db_password
backup_retention_period = 7 # Optional: Set backup retention if needed
}
Troubleshooting
AWS Documentation: Double-check the AWS RDS documentation for the specific MySQL version you are using and the supported instance classes.
Terraform Plan: Run terraform plan to ensure that your changes are correctly reflected and to review any additional issues that might come up.
Default storage type for RDS in terraform is gp2 where minimum size for MySQL is 20GB (you have only 10).
You can change it to 20 or specify ”standard” storage if you only want 10.
storage_type - (Optional) One of "standard" (magnetic), "gp2" (general purpose SSD), "gp3" (general purpose SSD that needs iops independently) or "io1" (provisioned IOPS SSD). The default is "io1" if iops is specified, "gp2" if not
thank for your comment!
i have fixed my source with your comment but i am getting same error..- Error Message
Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes aws_db_instance.example: Creating... ╷ │ Error: creating RDS DB Instance (terraform-up-and-running20240903153256753400000001): InvalidParameterCombination: RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.micro, Engine=mysql, EngineVersion=8.0.35, LicenseModel=general-public-license. For supported combinations of instance class and database engine version, see the documentation. │ status code: 400, request id: 3ee5c548-5db0-406a-b44a-3daab35dff79 │ │ with aws_db_instance.example, │ on main.tf line 25, in resource "aws_db_instance" "example": │ 25: resource "aws_db_instance" "example" {
- Fixed Source
resource "aws_db_instance" "example" { identifier_prefix = "terraform-up-and-running" engine = "mysql" allocated_storage = 20 # i fixed it instance_class = "db.t2.micro" skip_final_snapshot = true db_name = var.db_name username = var.db_username password = var.db_password }
I was able to correct the problem when I modified it based on the following solution. https://repost.aws/questions/QU1llceoaxT2Or7r4kcWKuDg/why-did-i-get-a-db-creating-error-from-terraform#ANlZkrmcLHQ6W0GCbB3kKnwA
However Your comments have given me a new perspective, thank you so much!
Relevant content
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 months ago
Thank you for your comment! I made the corrections as per your comment and was able to create it successfully! By the way, according to the documentation, db.t2.micro could no longer be created after June 1, 2024. https://docs.aws.amazon.com/en_en/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.Types.html I incredibly appreciate your help.