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

feat: Automated backups for Aurora PostgreSQL #608

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions aws-aurora-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ support_url: https://aws.amazon.com/rds/aurora/
tags: [aws, aurora, postgresql, postgres, beta]
plan_updateable: true
provision:
plan_inputs: []
user_inputs:
- field_name: instance_name
type: string
Expand Down Expand Up @@ -38,25 +39,25 @@ provision:
default: us-west-2
constraints:
examples:
- us-central1
- asia-northeast1
- us-central1
- asia-northeast1
pattern: ^[a-z][a-z0-9-]+$
prohibit_update: true
- field_name: serverless_min_capacity
type: number
nullable: true
- <<: &nullable_number
type: number
default: null
nullable: true
field_name: serverless_min_capacity
details: The minimum capacity for the cluster. Must be less than or equal to `serverless_max_capacity`. Valid capacity values are in a range of 0.5 up to 128 in steps of 0.5.
default: null
- field_name: serverless_max_capacity
type: number
nullable: true
- <<: *nullable_number
field_name: serverless_max_capacity
details: The maximum capacity for the cluster. Must be greater than or equal to `serverless_min_capacity`. Valid capacity values are in a range of 0.5 up to 128 in steps of 0.5.
default: null
- field_name: engine_version
type: string
nullable: true
- <<: &nullable_string
type: string
default: null
nullable: true
field_name: engine_version
details: The Aurora engine version, e.g. "13.7". Not all features are supported by all versions. Refer to the AWS documentation for more details.
default: null
- field_name: rds_subnet_group
type: string
details: AWS RDS subnet group already in existence to use
Expand All @@ -83,8 +84,29 @@ provision:
details: AWS secret key
default: ${config("aws.secret_access_key")}
- field_name: aws_vpc_id
type: string
details: VPC ID for instance
default: ""
- field_name: copy_tags_to_snapshot
type: boolean
default: true
details: Copy all cluster tags to snapshots
- field_name: backup_retention_period
type: number
details: |
The number of days (1-35) for which automatic backups are kept.
Automated backups cannot be disabled on Aurora.
The backup retention period determines the period for which you can perform a point-in-time recovery.
default: 1
constraints:
minimum: 1
maximum: 35
- <<: *nullable_string
field_name: preferred_backup_window
details: |
The daily time range in UTC during which automated backups are created, e.g.: "09:46-10:16".
Must not overlap with the maintenance window. If not set, uses the default for the region
(see https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Managing.Backups.html#Aurora.Managing.Backups.BackupWindow)
computed_inputs:
- name: labels
default: ${json.marshal(request.default_labels)}
Expand Down
6 changes: 6 additions & 0 deletions terraform-tests/aurora_postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var _ = Describe("Aurora postgresql", Label("aurora-postgresql-terraform"), Orde
"rds_vpc_security_group_ids": "",
"allow_major_version_upgrade": true,
"auto_minor_version_upgrade": true,
"backup_retention_period": 1,
"preferred_backup_window": "23:26-23:56",
"copy_tags_to_snapshot": true,
}

BeforeAll(func() {
Expand Down Expand Up @@ -83,6 +86,9 @@ var _ = Describe("Aurora postgresql", Label("aurora-postgresql-terraform"), Orde
"serverlessv2_scaling_configuration": BeEmpty(),
"allow_major_version_upgrade": BeTrue(),
"tags": HaveKeyWithValue("key1", "some-postgres-value"),
"backup_retention_period": BeNumerically("==", 1),
"preferred_backup_window": Equal("23:26-23:56"),
"copy_tags_to_snapshot": BeTrue(),
}))
})
})
Expand Down
3 changes: 3 additions & 0 deletions terraform/aurora-postgresql/provision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ resource "aws_rds_cluster" "cluster" {
vpc_security_group_ids = local.rds_vpc_security_group_ids
skip_final_snapshot = true
allow_major_version_upgrade = var.allow_major_version_upgrade
backup_retention_period = var.backup_retention_period
preferred_backup_window = var.preferred_backup_window
copy_tags_to_snapshot = var.copy_tags_to_snapshot

dynamic "serverlessv2_scaling_configuration" {
for_each = local.serverless ? [null] : []
Expand Down
5 changes: 4 additions & 1 deletion terraform/aurora-postgresql/provision/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ variable "engine_version" { type = string }
variable "rds_subnet_group" { type = string }
variable "rds_vpc_security_group_ids" { type = string }
variable "allow_major_version_upgrade" { type = bool }
variable "auto_minor_version_upgrade" { type = bool }
variable "auto_minor_version_upgrade" { type = bool }
variable "backup_retention_period" { type = number }
variable "preferred_backup_window" { type = string }
variable "copy_tags_to_snapshot" { type = bool }