Skip to content

Commit

Permalink
Improve rule S6249: fix Terraform code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
GabinL21 committed Nov 14, 2024
1 parent 007eef4 commit 6f73b3f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rules/S6249/terraform/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include::../recommended.adoc[]

No secure policy is attached to this bucket:

[source,terraform]
----
resource "aws_s3_bucket" "mynoncompliantbucket" { # Sensitive
bucket = "mynoncompliantbucketname"
Expand All @@ -16,6 +17,7 @@ resource "aws_s3_bucket" "mynoncompliantbucket" { # Sensitive

A policy is defined but forces only HTTPs communication for some users:

[source,terraform]
----
resource "aws_s3_bucket" "mynoncompliantbucket" { # Sensitive
bucket = "mynoncompliantbucketname"
Expand All @@ -31,9 +33,9 @@ resource "aws_s3_bucket_policy" "mynoncompliantbucketpolicy" {
{
Sid = "HTTPSOnly"
Effect = "Deny"
Principal = [
"arn:aws:iam::123456789123:root"
] # secondary location: only one principal is forced to use https
Principal = {
"AWS": "arn:aws:iam::123456789123:root"
} # secondary location: only one principal is forced to use https
Action = "s3:*"
Resource = [
aws_s3_bucket.mynoncompliantbucketpolicy.arn,
Expand Down Expand Up @@ -70,7 +72,9 @@ resource "aws_s3_bucket_policy" "mycompliantpolicy" {
{
Sid = "HTTPSOnly"
Effect = "Deny"
Principal = "*"
Principal = {
"AWS": "*"
}
Action = "s3:*"
Resource = [
aws_s3_bucket.mycompliantbucket.arn,
Expand Down

0 comments on commit 6f73b3f

Please sign in to comment.