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

CKV_AWS_145: Move from aws_s3_bucket to aws_s3_bucket_server_side_encryption_configuration #7014

Open
Malcolm-GetAHead opened this issue Feb 14, 2025 · 0 comments
Labels
checks Check additions or changes

Comments

@Malcolm-GetAHead
Copy link

Malcolm-GetAHead commented Feb 14, 2025

Describe the issue
It would be nice if the CKV_AWS_145 check could be moved from the aws_s3_bucket resource to the aws_s3_bucket_server_side_encryption_configuration resource. An additional check to see if the aws_s3_bucket resource has a aws_s3_bucket_server_side_encryption_configuration attached to it.

Attaching the check directly to aws_s3_bucket_server_side_encryption_configuration makes more sense and would allow ignore rules to be more specific.

Examples

variable "cloudfront_bucket" {
  type = bool
  description = "Is this a cloudfront bucket"
  default = false
}
variable "kms_arn" {
  type = string
  description = "KMS ARN for bucket encryption"
  default = null
}
resource "aws_s3_bucket" "this" {
  bucket        = "my-bucket"
}

resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
  count = var.cloudfront_bucket == false ? 1 : 0

  bucket = aws_s3_bucket.this.id

  rule {
    apply_server_side_encryption_by_default {
      kms_master_key_id = var.kms_arn
      sse_algorithm     = "aws:kms"
    }
    bucket_key_enabled = true
  }
}

resource "aws_s3_bucket_server_side_encryption_configuration" "cloudfront" {
  count = var.cloudfront_bucket == true ? 1 : 0

  bucket = aws_s3_bucket.this.id

  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "AES256"
    }
    bucket_key_enabled = true
  }
}

Version (please complete the following information):

  • Checkov Version 3.2.370

Additional context
Add any other context about the problem here.

@Malcolm-GetAHead Malcolm-GetAHead added the checks Check additions or changes label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checks Check additions or changes
Projects
None yet
Development

No branches or pull requests

1 participant