Skip to content

Commit

Permalink
Update Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
egon-okerman-sonarsource committed Nov 20, 2024
1 parent 3a22877 commit df93e49
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions rules/S6258/terraform/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,43 @@ resource "google_container_cluster" "example" {
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket[S3 access requests]:
[source,terraform]
----
resource "aws_s3_bucket" "example-logs" {
bucket = "example_logstorage"
acl = "log-delivery-write"
}
resource "aws_s3_bucket" "example" {
bucket = "example"
logging { # AWS provider <= 3
target_bucket = aws_s3_bucket.example-logs.id
target_prefix = "log/example"
}
}
resource "aws_s3_bucket_logging" "example" { # AWS provider >= 4
resource "aws_s3_bucket_logging" "example" {
bucket = aws_s3_bucket.example.id
target_bucket = aws_s3_bucket.example-logs.id
target_prefix = "log/example"
target_bucket = aws_s3_bucket.logs.id
target_prefix = "testing-logs"
}
# Set up a logging bucket
resource "aws_s3_bucket" "logs" {
bucket = "example_logstorage"
}
data "aws_iam_policy_document" "logs" {
statement {
sid = "s3-log-delivery"
effect = "Allow"
principals {
type = "Service"
identifiers = ["logging.s3.amazonaws.com"]
}
actions = ["s3:PutObject"]
resources = [
"${aws_s3_bucket.logs.arn}/*",
]
}
}
resource "aws_s3_bucket_policy" "logs" {
bucket = aws_s3_bucket.example-logs.id
policy = data.aws_iam_policy_document.example.json
}
----

Expand Down

0 comments on commit df93e49

Please sign in to comment.