Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for RestoreDBInstanceFromDBSnapshot AWS API from terraform #5228

Closed
psura opened this issue Jul 18, 2018 · 6 comments
Closed

Support for RestoreDBInstanceFromDBSnapshot AWS API from terraform #5228

psura opened this issue Jul 18, 2018 · 6 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@psura
Copy link

psura commented Jul 18, 2018

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Use case here is to restore aws rds from a snapshot. I would like is to just provide snapshot id and let aws figure out other details of the source instance from the snapshot and deploy a new rds instance.
I would like to make use of below AWS API through terraform
https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromDBSnapshot.html
As far as I can tell terraform does not support this API directly.
Today looks like I can do this by passing the snapshot id and making use of aws_db_instance resource (https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/data_source_aws_db_instance.go) which corresponds to https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
Correct me if I am wrong. Just getting hang on terraform api support and its mapping with aws api's.

I did not also see any examples that show aws rds restore from snapshot support without providing instance class and other details.

New or Affected Resource(s)

This looks like a new resource to me but I could be wrong. May be aws_db_instance can be updated to support the RestoreDBInstanceFromDBSnapshot AWS API?
Eventually I am also looking for support of Point in Time Restore from Terraform https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterToPointInTime.html

References

Only issue I found was this one that makes use of aws_db_instance resource
#473

@bflad bflad added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. service/rds Issues and PRs that pertain to the rds service. labels Jul 18, 2018
@bflad
Copy link
Contributor

bflad commented Jul 18, 2018

Hi @psura 👋 Are you looking for the snapshot_identifier argument for the aws_db_instance resource?

snapshot_identifier - (Optional) Specifies whether or not to create this database from a snapshot. This correlates to the snapshot ID you'd find in the RDS console, e.g: rds:production-2015-06-26-06-05.

Under the hood this is calling RestoreDBInstanceFromDBSnapshot:

https://github.com/terraform-providers/terraform-provider-aws/blob/d9073ca5d4dec68c6474fa0282441508f3072113/aws/resource_aws_db_instance.go#L662

As for your second part, Aurora cluster point in time restores are a completely different feature and we may have reservations about implementing them due to the ephemeral nature of making those types of requests.

Please let us know if this helps, thanks!

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 18, 2018
@psura
Copy link
Author

psura commented Jul 18, 2018

Hi @bflad thanks for your response. Yes I am providing the snapshot_identifier. But I am trying to avoid other details like instance_class. This will keep the restore flow quick and easy and I don't have to capture all these details in the state file for the source rds instances (which is what I am doing now as a workaround. Haven't tested it fully though).
Basically instance class is required in below code.

 opts := rds.RestoreDBInstanceFromDBSnapshotInput{
  	DBInstanceClass:         aws.String(d.Get("instance_class").(string)),

And when I make use of aws_db_instance resource I need to provide instance class and other details.

resource "aws_db_instance" "db_uat" { instance_class = "db.t2.micro" ....... snapshot_identifier = "${data.aws_db_snapshot.db_snapshot.id}" }

Even if I use module db resource using terraform-aws-modules I will have to provide all these details.
//# resources module "db" { source = "terraform-aws-modules/rds/aws" ... ... ... }

When I see the rds restore flow on aws console I see below call that seems to be getting all the required information using the name of the instance and passing it to the new instance being created:

Example Console Page: https://console.aws.amazon.com/rds/home?region=us-east-1#db-snapshots:

Here is the payload request as you see by inspecting the network calls from chrome browser
{"version":"1.0", "actions": [{"action":"com.amazonaws.console.rds.shared.DbInstanceContext.findById","parameters":["rds-instance-name"]}]}

The response to above call has all the required parameters including instance class which are being passed/ auto-filled in the restore screen on aws console.

Example Response:
{"actionResponses":[{"action":"com.amazonaws.console.rds.shared.DbInstanceContext.findById","data":{"engine":"postgres", ... ... ... **"DBInstanceClass":"db.r3.large"** ... }}]}

How can I simulate this with terraform?

As for your second part, Aurora cluster point in time restores are a completely different feature and we may have reservations about implementing them due to the ephemeral nature of making those types of requests.

Coming to point-in-time-restore support, even AWS RDS has that support not just AWS Aurora. Did not understand what you meant by "ephemeral nature". Can you share more details on why this is not a good candidate for supporting using terraform?
Also for AWS RDS, based on the transaction log size restore might take a very long time (in hours) but for aurora there are no transaction logs and restore time should be more predictable and faster as backups are incremental in nature.

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed waiting-response Maintainers are waiting on response from community or contributor. question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. labels Aug 1, 2018
@ghost
Copy link

ghost commented Feb 16, 2019

point-in-time-recovery for Aurora is a consistent solution for a cluster to be recovered during a rollback event. The requestor is correct that "for aurora there are no transaction logs and restore time should be more predictable and faster as backups are incremental in nature."

@dfuentes77
Copy link

dfuentes77 commented Apr 27, 2019

And the new Aurora clone feature that uses copy on write is cleaner and faster. And the feature is so old I’m surprised it’s not already supported.

https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBClusterToPointInTime.html

RestoreType as copy-on-write

@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Apr 16, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

3 participants