-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
fix: prevent creating empty replicas record #126
fix: prevent creating empty replicas record #126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bridgecrew has found infrastructure configuration errors in this PR ⬇️
main.tf
Outdated
@@ -134,7 +134,7 @@ resource "aws_rds_cluster" "primary" { | |||
|
|||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#replication_source_identifier | |||
resource "aws_rds_cluster" "secondary" { | |||
count = local.enabled && ! local.is_regional_cluster ? 1 : 0 | |||
count = local.enabled && !local.is_regional_cluster ? 1 : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure RDS instances have backup policy
Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_46
How to Fix
resource "aws_rds_cluster" "test" {
...
+ backup_retention_period = 35
}
Description
This check examines the attribute **backup_retention_period** this should have a value 1-35, and checks if its set to 0 which would disable the backup.This check is currently under review and maybe suppressed in future releases.
Dependent Resources
Path | Resource | Connecting Attribute |
---|---|---|
/main.tf | aws_rds_cluster_instance.default | depends_on |
cluster | coalesce(join(, aws_rds_cluster.primary.*.id), join(, aws_rds_cluster.secondary.*.id)) | resource_id |
main.tf
Outdated
@@ -134,7 +134,7 @@ resource "aws_rds_cluster" "primary" { | |||
|
|||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#replication_source_identifier | |||
resource "aws_rds_cluster" "secondary" { | |||
count = local.enabled && ! local.is_regional_cluster ? 1 : 0 | |||
count = local.enabled && !local.is_regional_cluster ? 1 : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure Postgres RDS has Query Logging enabled
Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_96
Description
TBD Dependent ResourcesPath | Resource | Connecting Attribute |
---|---|---|
/main.tf | aws_rds_cluster_instance.default | depends_on |
cluster | coalesce(join(, aws_rds_cluster.primary.*.id), join(, aws_rds_cluster.secondary.*.id)) | resource_id |
main.tf
Outdated
@@ -134,7 +134,7 @@ resource "aws_rds_cluster" "primary" { | |||
|
|||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#replication_source_identifier | |||
resource "aws_rds_cluster" "secondary" { | |||
count = local.enabled && ! local.is_regional_cluster ? 1 : 0 | |||
count = local.enabled && !local.is_regional_cluster ? 1 : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure RDS clusters have an AWS Backup backup plan
Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_49
How to Fix
resource "aws_rds_cluster" "rds_cluster_good" {
cluster_identifier = "aurora-cluster-demo"
engine = "aurora-mysql"
engine_version = "5.7.mysql_aurora.2.03.2"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
database_name = "mydb"
master_username = "foo"
master_password = "bar"
}
resource "aws_backup_plan" "example" {
name = "tf_example_backup_plan"
rule {
rule_name = "tf_example_backup_rule"
target_vault_name = "vault-name"
schedule = "cron(0 12 * * ? *)"
}
}
resource "aws_backup_selection" "backup_good" {
iam_role_arn = "arn:partition:service:region:account-id:resource-id"
name = "tf_example_backup_selection"
plan_id = aws_backup_plan.example.id
resources = [
aws_rds_cluster.rds_cluster_good.arn
]
}
Description
TBADependent Resources
Path | Resource | Connecting Attribute |
---|---|---|
/main.tf | aws_rds_cluster_instance.default | depends_on |
cluster | coalesce(join(, aws_rds_cluster.primary.*.id), join(, aws_rds_cluster.secondary.*.id)) | resource_id |
/test all |
what
cluster_size
< 1why
cluster_size = 0
this would result in an attempt to create an empty DNS record, which is not permitted by the Route53 APIreferences