-
Notifications
You must be signed in to change notification settings - Fork 0
Create ec2v3.tf #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,309 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| resource "aws_instance" "web_host" { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # ec2 have plain text secrets in user data | ||||||||||||||||||||||||||||||||||||||||||||||||
| ami = "${var.ami}" | ||||||||||||||||||||||||||||||||||||||||||||||||
| instance_type = "t2.nano" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| vpc_security_group_ids = [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| "${aws_security_group.web-node.id}"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| subnet_id = "${aws_subnet.web_subnet.id}" | ||||||||||||||||||||||||||||||||||||||||||||||||
| user_data = <<EOF | ||||||||||||||||||||||||||||||||||||||||||||||||
| #! /bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get update | ||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get install -y apache2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| sudo systemctl start apache2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| sudo systemctl enable apache2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMAAA | ||||||||||||||||||||||||||||||||||||||||||||||||
| export AWS_SECRET_ACCESS_KEY=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 | ||||||||||||||||||||||||||||||||||||||||||||||||
| export AWS_DEFAULT_REGION=us-west-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| echo "<h1>Deployed via Terraform</h1>" | sudo tee /var/www/html/index.html | ||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||
| tags = merge({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| Name = "${local.resource_prefix.value}-ec2" | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, { | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_commit = "d68d2897add9bc2203a5ed0632a5cdd8ff8cefb0" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_file = "terraform/aws/ec2.tf" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_last_modified_at = "2020-06-16 14:46:24" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_last_modified_by = "nimrodkor@gmail.com" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_modifiers = "nimrodkor" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_org = "bridgecrewio" | ||||||||||||||||||||||||||||||||||||||||||||||||
| git_repo = "terragoat" | ||||||||||||||||||||||||||||||||||||||||||||||||
| yor_trace = "347af3cd-4f70-4632-aca3-4d5e30ffc0b6" | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } | |
| ebs_optimized = true | |
| } |
EC2 EBS is not optimized
Resource: aws_instance.web_host | ID: BC_AWS_GENERAL_68
Description
TBAThere 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.
| } | |
| monitoring = true | |
| } |
Detailed monitoring for EC2 instances is disabled
Resource: aws_instance.web_host | ID: BC_AWS_LOGGING_26
Description
TBAThere 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.
| } | |
| *_block_device { | |
| encrypted = true | |
| } |
EBS volumes do not have encrypted launch configurations
Resource: aws_instance.web_host | ID: BC_AWS_GENERAL_13
Description
Amazon Elastic Block Store (EBS) volumes allow you to create encrypted launch configurations when creating EC2 instances and auto scaling. When the entire EBS volume is encrypted, data stored at rest on the volume, disk I/O, snapshots created from the volume, and data in-transit between EBS and EC2 are all encrypted.Benchmarks
- PCI-DSS V3.2 3
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 EBS Volume is encrypted by KMS using a customer managed Key (CMK)
Resource: aws_ebs_volume.web_host_storage | ID: BC_AWS_GENERAL_109
How to Fix
resource "aws_ebs_volume" "example" {
availability_zone = "us-west-2a"
size = 40
+ kms_key_id = "ckv_kms"
tags = {
Name = "HelloWorld"
}
}
Description
Amazon EBS automatically creates a unique AWS managed key in each Region where you store AWS resources. This KMS key has the alias alias/aws/ebs. By default, Amazon EBS uses this KMS key for encryption. Alternatively, you can specify a symmetric customer managed key that you created as the default KMS key for EBS encryption. Using your own KMS key gives you more flexibility, including the ability to create, rotate, and disable KMS keys.Dependent Resources
Calculating...
🎉 Fixed by commit b500196 - Create ec2v3.tf
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 EBS Volume is encrypted by KMS using a customer managed Key (CMK)
Resource: aws_ebs_volume.web_host_storage | ID: BC_AWS_GENERAL_109
How to Fix
resource "aws_ebs_volume" "example" {
availability_zone = "us-west-2a"
size = 40
+ kms_key_id = "ckv_kms"
tags = {
Name = "HelloWorld"
}
}
Description
Amazon EBS automatically creates a unique AWS managed key in each Region where you store AWS resources. This KMS key has the alias alias/aws/ebs. By default, Amazon EBS uses this KMS key for encryption. Alternatively, you can specify a symmetric customer managed key that you created as the default KMS key for EBS encryption. Using your own KMS key gives you more flexibility, including the ability to create, rotate, and disable KMS keys.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 EBS Volume is encrypted by KMS using a customer managed Key (CMK)
Resource: aws_ebs_volume.web_host_storage | ID: BC_AWS_GENERAL_109
How to Fix
resource "aws_ebs_volume" "example" {
availability_zone = "us-west-2a"
size = 40
+ kms_key_id = "ckv_kms"
tags = {
Name = "HelloWorld"
}
}
Description
Amazon EBS automatically creates a unique AWS managed key in each Region where you store AWS resources. This KMS key has the alias alias/aws/ebs. By default, Amazon EBS uses this KMS key for encryption. Alternatively, you can specify a symmetric customer managed key that you created as the default KMS key for EBS encryption. Using your own KMS key gives you more flexibility, including the ability to create, rotate, and disable KMS keys.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.
Not only encrypted EBS volumes are attached to EC2 instances
Resource: aws_ebs_volume.web_host_storage | ID: BC_AWS_GENERAL_60
How to Fix
resource "aws_instance" "web" {
ami = "ami-21f78e11"
availability_zone = "us-west-2a"
instance_type = "t2.micro"
tags = {
Name = "HelloWorld"
}
}
resource "aws_volume_attachment" "ok_attachment1" {
device_name = "/dev/sdh3"
volume_id = aws_ebs_volume.ok_ebs2.id
instance_id = aws_instance.web.id
}
resource "aws_ebs_volume" "ok_ebs2" {
availability_zone = ""
encrypted = true
}
Description
TBADependent Resources
Calculating...
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.
| } | |
| encrypted = true | |
| } |
AWS EBS volumes are not encrypted
Resource: aws_ebs_volume.web_host_storage | ID: BC_AWS_GENERAL_3
Description
Encrypting EBS volumes ensures that replicated copies of your images are secure even if they are accidentally exposed. AWS EBS encryption uses AWS KMS customer master keys (CMK) when creating encrypted volumes and snapshots. Storing EBS volumes in their encrypted state reduces the risk of data exposure or data loss. We recommend you encrypt all data stored in the EBS.Benchmarks
- PCI-DSS V3.2.1 3.4
- PCI-DSS V3.2 3
- NIST-800-53 SC-2
- FEDRAMP (MODERATE) SC-28
Calculating...
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.
Not every Security Group rule has a description
Resource: aws_security_group.web-node | ID: BC_AWS_NETWORKING_31
Description
Descriptions can be up to 255 characters long and can be set and viewed from the AWS Management Console, AWS Command Line Interface (CLI), and the AWS APIs.We recommend you add descriptive text to each of your Security Group Rules clarifying each rule's goals, this helps prevent developer errors.
Benchmarks
- SOC2 CC6.3.3
- ISO27001 A.10.1.1
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.
AWS Security Group allows all traffic on SSH port 22
Resource: aws_security_group.web-node | ID: BC_AWS_NETWORKING_1
Description
Security groups are stateful and provide filtering of ingress/egress network traffic to AWS resources. We recommend that security groups do not allow unrestricted ingress access to port 22. Removing unfettered connectivity to remote console services, such as SSH, reduces a server's exposure to risk.Benchmarks
- SOC2 CC6.3.3
- PCI-DSS V3.2.1 1.2.1, 1.3, 2.2.2
- PCI-DSS V3.2 2
- HIPAA 164.312(E)(1)
- NIST-800-53 AC-17, CA-3, CA-9, CM-3, SC-2
- ISO27001 A.10.1.1
- CIS AWS V1.2 4.1
- CIS AWS V1.3 5.2
- FEDRAMP (MODERATE) AC-4, SC-7, SC-7(3)
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.
AWS Security Group allows all traffic on SSH port 22
Resource: aws_security_group.web-node | ID: BC_AWS_NETWORKING_1
Description
Security groups are stateful and provide filtering of ingress/egress network traffic to AWS resources. We recommend that security groups do not allow unrestricted ingress access to port 22. Removing unfettered connectivity to remote console services, such as SSH, reduces a server's exposure to risk.Benchmarks
- SOC2 CC6.3.3
- PCI-DSS V3.2.1 1.2.1, 1.3, 2.2.2
- PCI-DSS V3.2 2
- HIPAA 164.312(E)(1)
- NIST-800-53 AC-17, CA-3, CA-9, CM-3, SC-2
- ISO27001 A.10.1.1
- CIS AWS V1.2 4.1
- CIS AWS V1.3 5.2
- FEDRAMP (MODERATE) AC-4, SC-7, SC-7(3)
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.
Not every Security Group rule has a description
Resource: aws_security_group.web-node | ID: BC_AWS_NETWORKING_31
Description
Descriptions can be up to 255 characters long and can be set and viewed from the AWS Management Console, AWS Command Line Interface (CLI), and the AWS APIs.We recommend you add descriptive text to each of your Security Group Rules clarifying each rule's goals, this helps prevent developer errors.
Benchmarks
- SOC2 CC6.3.3
- ISO27001 A.10.1.1
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.
AWS Default Security Group does not restrict all traffic
Resource: aws_vpc.web_vpc | ID: BC_AWS_NETWORKING_4
How to Fix
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.ok_vpc.id
}Description
A VPC comes with a default security group that has an initial setting denying all inbound traffic, allowing all outbound traffic, and allowing all traffic between instances assigned to the security group. If you do not specify a security group when you launch an instance, the instance is automatically assigned to this default security group. Security groups are stateful and provide filtering of ingress/egress network traffic to AWS resources.We recommend that your default security group restricts all inbound and outbound traffic. The default VPC in every region should have its default security group updated to comply with this recommendation. Any newly created VPCs will automatically contain a default security group that will need remediation to comply with this recommendation.
Configuring all VPC default security groups to restrict all traffic will encourage least privilege security group development and mindful placement of AWS resources into security groups. This in-turn reduces the exposure of those resources.
Benchmarks
- SOC2 CC6.3.3
- PCI-DSS V3.2.1 1.3, 2.1
- PCI-DSS V3.2 2
- HIPAA 164.312(E)(1)
- NIST-800-53 AC-17, CA-3, CA-9, CM-3, SC-2
- ISO27001 A.13.1.3
- CIS AWS V1.2 4.4
- FEDRAMP (MODERATE) AC-4, SC-7, SC-7(3)
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.
AWS Default Security Group does not restrict all traffic
Resource: aws_vpc.web_vpc | ID: BC_AWS_NETWORKING_4
How to Fix
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.ok_vpc.id
}Description
A VPC comes with a default security group that has an initial setting denying all inbound traffic, allowing all outbound traffic, and allowing all traffic between instances assigned to the security group. If you do not specify a security group when you launch an instance, the instance is automatically assigned to this default security group. Security groups are stateful and provide filtering of ingress/egress network traffic to AWS resources.We recommend that your default security group restricts all inbound and outbound traffic. The default VPC in every region should have its default security group updated to comply with this recommendation. Any newly created VPCs will automatically contain a default security group that will need remediation to comply with this recommendation.
Configuring all VPC default security groups to restrict all traffic will encourage least privilege security group development and mindful placement of AWS resources into security groups. This in-turn reduces the exposure of those resources.
Benchmarks
- SOC2 CC6.3.3
- PCI-DSS V3.2.1 1.3, 2.1
- PCI-DSS V3.2 2
- HIPAA 164.312(E)(1)
- NIST-800-53 AC-17, CA-3, CA-9, CM-3, SC-2
- ISO27001 A.13.1.3
- CIS AWS V1.2 4.4
- FEDRAMP (MODERATE) AC-4, SC-7, SC-7(3)
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 VPC subnets do not assign public IP by default
Resource: aws_subnet.web_subnet | ID: BC_AWS_NETWORKING_53
How to Fix
resource "aws_subnet" "test" {
...
+ map_public_ip_on_launch = false
}Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.Dependent Resources
Calculating...
🎉 Fixed by commit b500196 - Create ec2v3.tf
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.
| resource "aws_subnet" "web_subnet" { |
VPC subnets should not allow automatic public IP assignment
Resource: aws_subnet.web_subnet | ID: BC_AWS_NETWORKING_53
Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.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.
| map_public_ip_on_launch = true |
VPC subnets should not allow automatic public IP assignment
Resource: aws_subnet.web_subnet | ID: BC_AWS_NETWORKING_53
Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.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 VPC subnets do not assign public IP by default
Resource: aws_subnet.web_subnet2 | ID: BC_AWS_NETWORKING_53
How to Fix
resource "aws_subnet" "test" {
...
+ map_public_ip_on_launch = false
}Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.Dependent Resources
Calculating...
🎉 Fixed by commit b500196 - Create ec2v3.tf
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.
| resource "aws_subnet" "web_subnet2" { |
VPC subnets should not allow automatic public IP assignment
Resource: aws_subnet.web_subnet2 | ID: BC_AWS_NETWORKING_53
Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.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.
| map_public_ip_on_launch = true |
VPC subnets should not allow automatic public IP assignment
Resource: aws_subnet.web_subnet2 | ID: BC_AWS_NETWORKING_53
Description
VPC subnet is a part of the VPC having its own rules for traffic. Assigning the Public IP to the subnet automatically (on launch) can accidentally expose the instances within this subnet to internet and should be edited to 'No' post creation of the Subnet.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 S3 buckets are encrypted with KMS by default
Resource: aws_s3_bucket.flowbucket | 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
TBADependent Resources
Calculating...
🎉 Fixed by commit b500196 - Create ec2v3.tf
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 S3 bucket has cross-region replication enabled
Resource: aws_s3_bucket.flowbucket | 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.Dependent Resources
Calculating...
🎉 Fixed by commit b500196 - Create ec2v3.tf
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.
| resource "aws_s3_bucket" "flowbucket" { | |
| server_side_encryption_configuration { | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "aws:kms" | |
| } | |
| } | |
| } | |
| } |
S3 buckets are not encrypted with KMS
Resource: aws_s3_bucket.flowbucket | ID: BC_AWS_GENERAL_56
Description
TBAThere 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.
| resource "aws_s3_bucket" "flowbucket" { | |
| versioning { | |
| enabled = true | |
| } | |
| } |
AWS S3 object versioning is disabled
Resource: aws_s3_bucket.flowbucket | 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
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.
S3 bucket cross-region replication disabled
Resource: aws_s3_bucket.flowbucket | 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.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.
terraform build demo
Resource: aws_s3_bucket.flowbucket | ID: 807152304871829504_AWS_1643881781204
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.
S3 Bucket does not have public access blocks
Resource: aws_s3_bucket.flowbucket | 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.
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.
All S3 Buckets must have a tag with key Classification and have versioning enabled
Resource: aws_s3_bucket.flowbucket | ID: 807152304871829504_AWS_1643813941482
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.
AWS access logging not enabled on S3 buckets
Resource: aws_s3_bucket.flowbucket | ID: BC_AWS_S3_13
How to Fix
resource "aws_s3_bucket" "bucket" {
acl = var.s3_bucket_acl
bucket = var.s3_bucket_name
policy = var.s3_bucket_policy
force_destroy = var.s3_bucket_force_destroy
versioning {
enabled = var.versioning
mfa_delete = var.mfa_delete
}
+ dynamic "logging" {
+ for_each = var.logging
+ content {
+ target_bucket = logging.value["target_bucket"]
+ target_prefix = "log/${var.s3_bucket_name}"
+ }
+ }
}Description
Access logging provides detailed audit logging for all objects and folders in an S3 bucket.Benchmarks
- HIPAA 164.312(B) Audit controls
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.
| resource "aws_s3_bucket" "flowbucket" { | |
| server_side_encryption_configuration { | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "AES256" | |
| } | |
| } | |
| } | |
| } |
Data stored in the S3 bucket is not securely encrypted at rest
Resource: aws_s3_bucket.flowbucket | 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.1 3.4
- PCI-DSS V3.2 3
- NIST-800-53 AC-17, SC-2
- CIS AWS V1.3 2.1.1
- FEDRAMP (MODERATE) SC-28
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.
S3 bucket cross-region replication disabled
Resource: aws_s3_bucket.flowbucket | 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.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.
terraform build demo
Resource: aws_s3_bucket.flowbucket | ID: 807152304871829504_AWS_1643881781204
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.
AWS access logging not enabled on S3 buckets
Resource: aws_s3_bucket.flowbucket | ID: BC_AWS_S3_13
How to Fix
resource "aws_s3_bucket" "bucket" {
acl = var.s3_bucket_acl
bucket = var.s3_bucket_name
policy = var.s3_bucket_policy
force_destroy = var.s3_bucket_force_destroy
versioning {
enabled = var.versioning
mfa_delete = var.mfa_delete
}
+ dynamic "logging" {
+ for_each = var.logging
+ content {
+ target_bucket = logging.value["target_bucket"]
+ target_prefix = "log/${var.s3_bucket_name}"
+ }
+ }
}Description
Access logging provides detailed audit logging for all objects and folders in an S3 bucket.Benchmarks
- HIPAA 164.312(B) Audit controls
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.
All S3 Buckets must have a tag with key Classification and have versioning enabled
Resource: aws_s3_bucket.flowbucket | ID: 807152304871829504_AWS_1643813941482
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.
S3 Bucket does not have public access blocks
Resource: aws_s3_bucket.flowbucket | 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.
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.
| } | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "aws:kms" | |
| } | |
| } | |
| } | |
| } |
S3 buckets are not encrypted with KMS
Resource: aws_s3_bucket.flowbucket | ID: BC_AWS_GENERAL_56
Description
TBAThere 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.
| } | |
| rule { | |
| apply_server_side_encryption_by_default { | |
| sse_algorithm = "AES256" | |
| } | |
| } | |
| } | |
| } |
Data stored in the S3 bucket is not securely encrypted at rest
Resource: aws_s3_bucket.flowbucket | 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.1 3.4
- PCI-DSS V3.2 3
- NIST-800-53 AC-17, SC-2
- CIS AWS V1.3 2.1.1
- FEDRAMP (MODERATE) SC-28
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.
| } | |
| versioning { | |
| enabled = true | |
| } | |
| } |
AWS S3 object versioning is disabled
Resource: aws_s3_bucket.flowbucket | 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
Uh oh!
There was an error while loading. Please reload this page.
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.
Resource: aws_instance.web_host | ID:
BC_AWS_GENERAL_13Description
Amazon Elastic Block Store (EBS) volumes allow you to create encrypted launch configurations when creating EC2 instances and auto scaling. When the entire EBS volume is encrypted, data stored at rest on the volume, disk I/O, snapshots created from the volume, and data in-transit between EBS and EC2 are all encrypted.Benchmarks