-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
executable file
·27 lines (24 loc) · 1.05 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
provider "aws" {
region = "eu-west-1" # put your AWS region here!
}
# Get latest snapshot from production DB
data "aws_db_snapshot" "latest_prod_snapshot" {
most_recent = true
db_instance_identifier = "mydbname" # put the name of your db here!
}
# Create new staging DB
resource "aws_db_instance" "db_snapshot_dumper" {
instance_class = "db.t2.micro"
identifier = "db-snapshot-dumper"
username = "user" # necessary, but won't be used since a snapshot identifier is provided...
password = "password" # necessary, but won't be used since a snapshot identifier is provided...
snapshot_identifier = "${data.aws_db_snapshot.latest_prod_snapshot.id}"
#vpc_security_group_ids = ["sg-12345678"] # if you are running inside a VPC uncomment and put yours here
skip_final_snapshot = true # Won't produce a final snapshot when disposing of db
}
output "address" {
value = "${aws_db_instance.db_snapshot_dumper.address}"
}
output "snapshot" {
value = "${aws_db_instance.db_snapshot_dumper.snapshot_identifier}"
}