Complete the code to enable automated backups for an RDS instance.
resource "aws_db_instance" "example" { allocated_storage = 20 engine = "mysql" instance_class = "db.t3.micro" name = "mydb" username = "admin" password = "password" backup_retention_period = [1] }
The backup_retention_period must be set to a positive integer to enable automated backups. Setting it to 7 means backups are retained for 7 days.
Complete the code to create a manual snapshot of an RDS instance.
resource "aws_db_snapshot" "manual_snapshot" { db_instance_identifier = "mydb-instance" db_snapshot_identifier = [1] }
The db_snapshot_identifier must be a quoted string that uniquely identifies the snapshot. Quotes are required for string values.
Fix the error in the code to enable point-in-time recovery for an RDS instance.
resource "aws_db_instance" "example" { allocated_storage = 20 engine = "postgres" instance_class = "db.t3.micro" name = "mydb" username = "admin" password = "password" backup_retention_period = 7 [1] = true }
The correct attribute to enable point-in-time recovery is enable_point_in_time_recovery set to true.
Fill both blanks to configure a lifecycle policy that deletes automated backups after 14 days and enables backup window at 03:00.
resource "aws_db_instance" "example" { allocated_storage = 20 engine = "mysql" instance_class = "db.t3.micro" name = "mydb" username = "admin" password = "password" backup_retention_period = [1] preferred_backup_window = [2] }
Setting backup_retention_period to 14 keeps backups for 14 days. The preferred_backup_window set to "03:00-04:00" schedules backups during that hour.
Fill all three blanks to create a snapshot resource with identifier 'prod-snapshot-01', linked to instance 'prod-db', and with a tag 'Environment' set to 'Production'.
resource "aws_db_snapshot" "prod_snapshot" { db_instance_identifier = [1] db_snapshot_identifier = [2] tags = { Environment = [3] } }
The db_instance_identifier must be the instance name "prod-db". The db_snapshot_identifier is the snapshot name "prod-snapshot-01". The tag value for Environment is "Production".