aws_db_snapshot and aws_db_instance

101 views
Skip to first unread message

Darryl Mendez

unread,
Jun 14, 2018, 7:29:00 AM6/14/18
to Terraform
Hi all,
I have an issue with aws_db_snapshot, I am trying to clone the Production db instance to a new DB Instance which will become the new Production DB Instance.
I have done the below for that 
data "aws_db_snapshot" "db_snapshot" {
  most_recent            = true
  db_instance_identifier = "${var.db-instance-identifier-snapshot}"
}

resource "aws_db_instance" "oracle" {
  allocated_storage       = "${var.rds_allocated_storage}"
  engine                  = "${var.rds_oracle_engine}"
  engine_version          = "${var.rds_engine_version}"
  iops                    = "${var.rds_iops}"
  instance_class          = "${var.rds_instance_class}"
  identifier              = "${var.rds_identifier}"
  name                    = "${var.rds_db_name}"
  username                = "${var.rds_user}"
  password                = "${var.rds_password}"
  db_subnet_group_name    = "${aws_db_subnet_group.oracle-subnet.name}"
  snapshot_identifier     = "${data.aws_db_snapshot.db_snapshot.id}"
  parameter_group_name    = "${aws_db_parameter_group.oracle-parameters.name}"
  multi_az                = "false"
  vpc_security_group_ids  = ["${aws_security_group.allow-oracle.id}"]
  storage_type            = "${var.rds_storage_type}"
  backup_retention_period = "${var.rds_backup_retention}"
  availability_zone       = "${aws_subnet.main-private-1.availability_zone}"
  skip_final_snapshot     = "${var.skip_final_snapshot}"

  tags {
    Name = "${var.app-db-instance-name}"
  }
However it is failing with an error, your query returned no results. I verified the snapshot is valid.
Please help.



Capture2.PNG
Capture.PNG

Darryl Mendez

unread,
Jun 14, 2018, 11:50:24 AM6/14/18
to terrafo...@googlegroups.com
Hi all, I've found a workaround by adding the hard coding the snapshot identifier in the resource "aws_db_instance". However it would have been ideal if the latest snapshot is picked by terraform without hard coding. I' haven't tested it, but terraform plan does not complain any more.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/1d77183a-007c-4be1-9b4c-5527ae15a7b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Sincerely,
Darryl Mendez
Reply all
Reply to author
Forward
0 new messages