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

chore: set retention period only when enabling functionality #539

Merged
merged 5 commits into from
Oct 10, 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
31 changes: 31 additions & 0 deletions terraform-tests/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,35 @@ var _ = Describe("mysql", Label("mysql-terraform"), Ordered, func() {

})

Context("performance_insights", func() {
When("is not enabled", func() {
BeforeAll(func() {
plan = ShowPlan(terraformProvisionDir, buildVars(defaultVars, map[string]any{"performance_insights_enabled": false}))
})
It("should not set performance_insights_retention_period", func() {
Expect(AfterValuesForType(plan, "aws_db_instance")).To(Not(HaveKey("performance_insights_retention_period")))
})
})

When("is enabled", func() {
retentionPeriod := 7
BeforeAll(func() {
plan = ShowPlan(terraformProvisionDir, buildVars(
defaultVars,
map[string]any{
"performance_insights_enabled": true,
"performance_insights_retention_period": retentionPeriod,
},
))
})
It("should set the passed value for performance_insights_retention_period", func() {
Expect(AfterValuesForType(plan, "aws_db_instance")).To(
MatchKeys(IgnoreExtras, Keys{
"performance_insights_enabled": Equal(true),
"performance_insights_retention_period": BeNumerically("==", retentionPeriod),
}))
})
})
})

})
32 changes: 32 additions & 0 deletions terraform-tests/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,36 @@ var _ = Describe("postgres", Label("postgres-terraform"), Ordered, func() {
})
})
})

Context("performance_insights", func() {
When("is not enabled", func() {
BeforeAll(func() {
plan = ShowPlan(terraformProvisionDir, buildVars(defaultVars, map[string]any{"performance_insights_enabled": false}))
})
It("should not set performance_insights_retention_period", func() {
Expect(AfterValuesForType(plan, "aws_db_instance")).To(Not(HaveKey("performance_insights_retention_period")))
})
})

When("is enabled", func() {
retentionPeriod := 7
BeforeAll(func() {
plan = ShowPlan(terraformProvisionDir, buildVars(
defaultVars,
map[string]any{
"performance_insights_enabled": true,
"performance_insights_retention_period": retentionPeriod,
},
))
})
It("should set the passed value for performance_insights_retention_period", func() {
Expect(AfterValuesForType(plan, "aws_db_instance")).To(
MatchKeys(IgnoreExtras, Keys{
"performance_insights_enabled": Equal(true),
"performance_insights_retention_period": BeNumerically("==", retentionPeriod),
}))
})
})
})

})
2 changes: 1 addition & 1 deletion terraform/mysql/provision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ resource "aws_db_instance" "db_instance" {
monitoring_role_arn = var.monitoring_role_arn
performance_insights_enabled = var.performance_insights_enabled
performance_insights_kms_key_id = var.performance_insights_kms_key_id == "" ? null : var.performance_insights_kms_key_id
performance_insights_retention_period = var.performance_insights_retention_period
performance_insights_retention_period = var.performance_insights_enabled ? var.performance_insights_retention_period : null

lifecycle {
prevent_destroy = true
Expand Down
2 changes: 1 addition & 1 deletion terraform/postgresql/provision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ resource "aws_db_instance" "db_instance" {
monitoring_role_arn = var.monitoring_role_arn
performance_insights_enabled = var.performance_insights_enabled
performance_insights_kms_key_id = var.performance_insights_kms_key_id == "" ? null : var.performance_insights_kms_key_id
performance_insights_retention_period = var.performance_insights_retention_period
performance_insights_retention_period = var.performance_insights_enabled ? var.performance_insights_retention_period : null

lifecycle {
prevent_destroy = true
Expand Down