Conversation
| Environment = local.resource_prefix.value | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
| } | |
| } | |
| resource "aws_s3_bucket_server_side_encryption_configuration" "financials" { | |
| bucket = aws_s3_bucket.financials.bucket | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "aws:kms" | |
| } | |
| } | |
| } | |
Ensure S3 buckets are encrypted with KMS by default
Resource: aws_s3_bucket.financials | ID: BC_AWS_GENERAL_56
Description
TBA| # bucket is not encrypted | ||
| bucket = "${local.resource_prefix.value}-data-science" | ||
| acl = "private" | ||
|
|
There was a problem hiding this comment.
Ensure data stored in the S3 bucket is securely encrypted at rest
Resource: aws_s3_bucket.data_science | ID: BC_AWS_S3_14
How to Fix
resource "aws_s3_bucket" "example" {
...
+ server_side_encryption_configuration {
+ rule {
+ apply_server_side_encryption_by_default {
+ sse_algorithm = "AES256"
+ }
+ }
+ }
}Description
SSE helps prevent unauthorized access to S3 buckets. Encrypting and decrypting data at the S3 bucket level is transparent to users when accessing data.Benchmarks
- PCI-DSS V3.2 3
- NIST-800-53 AC-17, SC-2
- PCI-DSS V3.2.1 3.4
- FEDRAMP (MODERATE) SC-28
- CIS AWS V1.3 2.1.1
| # bucket is not encrypted | ||
| bucket = "${local.resource_prefix.value}-data-science" | ||
| acl = "private" | ||
|
|
There was a problem hiding this comment.
Ensure AWS resources that support tags have Tags
Resource: aws_s3_bucket.data_science | ID: BC_AWS_GENERAL_26
How to Fix
resource "aws_security_group" "sg" {
name = "my-sg"
...
+ tags = {
+ Environment = "dev"
+ Owner = "apps-team"
+ }
}Description
Many different types of AWS resources support tags. Tags allow you to add metadata to a resource to help identify ownership, perform cost / billing analysis, and to enrich a resource with other valuable information, such as descriptions and environment names. While there are many ways that tags can be used, we recommend you follow a tagging practice.View AWS's recommended tagging best practices here.
| } | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "financials" { |
There was a problem hiding this comment.
Ensure S3 Bucket has public access blocks
Resource: aws_s3_bucket.financials | ID: BC_AWS_NETWORKING_52
How to Fix
resource "aws_s3_bucket" "bucket_good_1" {
bucket = "bucket_good"
}
resource "aws_s3_bucket_public_access_block" "access_good_1" {
bucket = aws_s3_bucket.bucket_good_1.id
block_public_acls = true
block_public_policy = true
}
Description
When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.
| tags = { | ||
| Name = "${local.resource_prefix.value}-customer-master" | ||
| Environment = local.resource_prefix.value | ||
|
|
There was a problem hiding this comment.
Ensure S3 bucket Object is encrypted by KMS using a customer managed Key (CMK)
Resource: aws_s3_bucket_object.data_object | ID: BC_AWS_GENERAL_106
How to Fix
resource "aws_s3_bucket_object" "object" {
bucket = "your_bucket_name"
key = "new_object_key"
source = "path/to/file"
+ kms_key_id = "ckv_kms"
# The filemd5() function is available in Terraform 0.11.12 and later
# For Terraform 0.11.11 and earlier, use the md5() function and the file() function:
# etag = "${md5(file("path/to/file"))}"
etag = filemd5("path/to/file")
}
Description
This is a simple check to ensure that the S3 bucket Object is using AWS key management - KMS to encrypt its contents. To resolve add the ARN of your KMS or link on creation of the object.| Environment = local.resource_prefix.value | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
| } | |
| } | |
| resource "aws_s3_bucket_versioning" "financials" { | |
| bucket = aws_s3_bucket.financials.id | |
| versioning_configuration { | |
| status = "Enabled" | |
| } | |
| } | |
Ensure AWS S3 object versioning is enabled
Resource: aws_s3_bucket.financials | ID: BC_AWS_S3_16
Description
S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.
Benchmarks
- PCI-DSS V3.2.1 10.5.3
- FEDRAMP (MODERATE) CP-10, SI-12
|
|
||
| } | ||
|
|
||
| resource "aws_s3_bucket" "operations" { |
There was a problem hiding this comment.
Ensure AWS S3 object versioning is enabled
Resource: aws_s3_bucket.operations | ID: BC_AWS_S3_16
How to Fix
resource "aws_s3_bucket" "state_bucket" {
bucket = "${data.aws_caller_identity.current.account_id}-terraform-state"
acl = var.acl
force_destroy = var.force_destroy
+ versioning {
+ enabled = true
+ }
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = var.sse_algorithm
}
}
}
tags = var.common_tags
}Description
S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.
Benchmarks
- PCI-DSS V3.2.1 10.5.3
- FEDRAMP (MODERATE) CP-10, SI-12
| acl = "private" | ||
|
|
||
| versioning { | ||
| enabled = false |
There was a problem hiding this comment.
| enabled = false | |
| enabled = true |
Ensure AWS S3 object versioning is enabled
Resource: aws_s3_bucket.data_science | ID: BC_AWS_S3_16
Description
S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.
Benchmarks
- PCI-DSS V3.2.1 10.5.3
- FEDRAMP (MODERATE) CP-10, SI-12
| # bucket is not encrypted | ||
| bucket = "${local.resource_prefix.value}-data-science" | ||
| acl = "private" | ||
|
|
There was a problem hiding this comment.
Ensure S3 buckets are encrypted with KMS by default
Resource: aws_s3_bucket.data_science | ID: BC_AWS_GENERAL_56
How to Fix
resource "aws_s3_bucket" "mybucket" {
...
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.mykey.arn
+ sse_algorithm = "aws:kms"
}
}
}
}Description
TBA| # bucket is not encrypted | ||
| bucket = "${local.resource_prefix.value}-data-science" | ||
| acl = "private" | ||
|
|
There was a problem hiding this comment.
Ensure S3 bucket has cross-region replication enabled
Resource: aws_s3_bucket.data_science | ID: BC_AWS_GENERAL_72
How to Fix
resource "aws_s3_bucket" "test" {
...
+ replication_configuration {
+ role = aws_iam_role.replication.arn
+ rules {
+ id = "foobar"
+ prefix = "foo"
+ status = "Enabled"
+
+ destination {
+ bucket = aws_s3_bucket.destination.arn
+ storage_class = "STANDARD"
+ }
+ }
+ }
}Description
Cross-region replication enables automatic, asynchronous copying of objects across S3 buckets. By default, replication supports copying new S3 objects after it is enabled. It is also possible to use replication to copy existing objects and clone them to a different bucket, but in order to do so, you must contact AWS Support.| Environment = local.resource_prefix.value | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
| } | |
| } | |
| resource "aws_s3_bucket_server_side_encryption_configuration" "financials" { | |
| bucket = aws_s3_bucket.financials.bucket | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "AES256" | |
| } | |
| } | |
| } | |
Ensure data stored in the S3 bucket is securely encrypted at rest
Resource: aws_s3_bucket.financials | ID: BC_AWS_S3_14
Description
SSE helps prevent unauthorized access to S3 buckets. Encrypting and decrypting data at the S3 bucket level is transparent to users when accessing data.Benchmarks
- PCI-DSS V3.2 3
- NIST-800-53 AC-17, SC-2
- PCI-DSS V3.2.1 3.4
- FEDRAMP (MODERATE) SC-28
- CIS AWS V1.3 2.1.1
| # bucket is not encrypted | ||
| bucket = "${local.resource_prefix.value}-data-science" | ||
| acl = "private" | ||
|
|
There was a problem hiding this comment.
Ensure S3 Bucket has public access blocks
Resource: aws_s3_bucket.data_science | ID: BC_AWS_NETWORKING_52
How to Fix
resource "aws_s3_bucket" "bucket_good_1" {
bucket = "bucket_good"
}
resource "aws_s3_bucket_public_access_block" "access_good_1" {
bucket = aws_s3_bucket.bucket_good_1.id
block_public_acls = true
block_public_policy = true
}
Description
When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.
| Environment = local.resource_prefix.value | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
| } | |
| } | |
| resource "aws_s3_bucket_versioning" "financials" { | |
| bucket = aws_s3_bucket.financials.id | |
| versioning_configuration { | |
| status = "Enabled" | |
| } | |
| } | |
| resource "aws_s3_bucket" "destination" { | |
| bucket = aws_s3_bucket.financials.id | |
| versioning_configuration { | |
| status = "Enabled" | |
| } | |
| } | |
| resource "aws_iam_role" "replication" { | |
| name = "aws-iam-role" | |
| assume_role_policy = <<POLICY | |
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Action": "sts:AssumeRole", | |
| "Principal": { | |
| "Service": "s3.amazonaws.com" | |
| }, | |
| "Effect": "Allow", | |
| "Sid": "" | |
| } | |
| ] | |
| } | |
| POLICY | |
| } | |
| resource "aws_s3_bucket_replication_configuration" "financials" { | |
| depends_on = [aws_s3_bucket_versioning.financials] | |
| role = aws_iam_role.financials.arn | |
| bucket = aws_s3_bucket.financials.id | |
| rule { | |
| id = "foobar" | |
| status = "Enabled" | |
| destination { | |
| bucket = aws_s3_bucket.destination.arn | |
| storage_class = "STANDARD" | |
| } | |
| } | |
| } | |
Ensure S3 bucket has cross-region replication enabled
Resource: aws_s3_bucket.financials | ID: BC_AWS_GENERAL_72
Description
Cross-region replication enables automatic, asynchronous copying of objects across S3 buckets. By default, replication supports copying new S3 objects after it is enabled. It is also possible to use replication to copy existing objects and clone them to a different bucket, but in order to do so, you must contact AWS Support.|
|
||
| } | ||
|
|
||
| resource "aws_s3_bucket" "operations" { |
There was a problem hiding this comment.
Ensure S3 Bucket has public access blocks
Resource: aws_s3_bucket.operations | ID: BC_AWS_NETWORKING_52
How to Fix
resource "aws_s3_bucket" "bucket_good_1" {
bucket = "bucket_good"
}
resource "aws_s3_bucket_public_access_block" "access_good_1" {
bucket = aws_s3_bucket.bucket_good_1.id
block_public_acls = true
block_public_policy = true
}
Description
When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.
| Environment = local.resource_prefix.value | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
| } | |
| } | |
| resource "aws_s3_bucket" "financials_log_bucket" { | |
| bucket = "financials-log-bucket" | |
| } | |
| resource "aws_s3_bucket_logging" "financials" { | |
| bucket = aws_s3_bucket.financials.id | |
| target_bucket = aws_s3_bucket.financials_log_bucket.id | |
| target_prefix = "log/" | |
| } | |
Ensure AWS access logging is enabled on S3 buckets
Resource: aws_s3_bucket.financials | ID: BC_AWS_S3_13
Description
Access logging provides detailed audit logging for all objects and folders in an S3 bucket.Benchmarks
- HIPAA 164.312(B) Audit controls
No description provided.