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

Add support for disabling egress traffic #130

Merged
merged 6 commits into from
Jan 25, 2022

Conversation

jalgraves
Copy link
Contributor

what

  • Add support for disabling egress security-group rule in default security group

why

tl;dr My boss told me to.

We had a third party do a pen test and afterwards they suggested we remove egress traffic from our DB subnets. If I'm missing something and there is another way to accomplish this without changing the module I'd be happy and grateful to hear it.

Copy link

@bridgecrew bridgecrew bot left a 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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   Ensure RDS clusters and instances have deletion protection enabled
    Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_69
Error in referred variable: variable "deletion_protection"

How to Fix

resource "aws_rds_cluster" "default" {
  ...
+ deletion_protection = true
}

Description

TBA

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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   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

TBA

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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure RDS cluster has IAM authentication enabled
    Resource: aws_rds_cluster.secondary | ID: BC_AWS_IAM_66
Error in referred variable: variable "iam_database_authentication_enabled"

How to Fix

resource "aws_rds_cluster" "enabled" {
	...
+ iam_database_authentication_enabled = true
}

Description

TBD

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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH   Ensure all data stored in Aurora is securely encrypted at rest
    Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_38
Error in referred variable: variable "storage_encrypted"

How to Fix

resource "aws_rds_cluster" "example" {
  ...
  cluster_identifier      = "aurora-cluster-demo"
+ storage_encrypted       = true
  ...
}

Description

This policy examines the resource **aws_rds_cluster** to check that encryption is set up. The property **storage_encrypted** is examined.

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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW   Ensure Amazon RDS clusters and instances have AWS IAM authentication enabled
    Resource: aws_rds_cluster.secondary | ID: BC_AWS_IAM_59
Error in referred variable: variable "iam_database_authentication_enabled"

How to Fix

resource "aws_rds_cluster" "default" {
  cluster_identifier      = "aurora-cluster-demo"
	...
+  iam_database_authentication_enabled = true
}

Description

TBA. Identity and Access Management (IAM)

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
Copy link

@bridgecrew bridgecrew bot Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM   Ensure Postgres RDS has Query Logging enabled
    Resource: aws_rds_cluster.secondary | ID: BC_AWS_GENERAL_96

@jalgraves jalgraves marked this pull request as ready for review January 24, 2022 23:08
@jalgraves jalgraves requested review from a team as code owners January 24, 2022 23:08
@Gowiem
Copy link
Member

Gowiem commented Jan 24, 2022

/test all

Gowiem
Gowiem previously requested changes Jan 25, 2022
variables.tf Outdated Show resolved Hide resolved
@mergify mergify bot dismissed Gowiem’s stale review January 25, 2022 18:46

This Pull Request has been updated, so we're dismissing all reviews.

@jalgraves jalgraves requested a review from Gowiem January 25, 2022 18:47
@Gowiem
Copy link
Member

Gowiem commented Jan 25, 2022

/test all

@Gowiem Gowiem merged commit 28e76de into cloudposse:master Jan 25, 2022
@jalgraves jalgraves deleted the disable-egress branch January 25, 2022 20:53
@Gowiem
Copy link
Member

Gowiem commented Jan 25, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants