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

aws s3 policy s3EnforceUserAcl update #828

Merged
merged 1 commit into from
Jun 2, 2021
Merged

aws s3 policy s3EnforceUserAcl update #828

merged 1 commit into from
Jun 2, 2021

Conversation

gaurav-gogia
Copy link
Contributor

provider "aws" {
  region = "us-east-1"
}


resource "aws_s3_bucket" "no_policy" {
  bucket = "frontend-access-logs"
  acl    = "private"

  versioning {
    enabled = true
  }

  logging {
    target_bucket = "log-bucket"
    target_prefix = "AWSLogs/frontend-lb-access-logs/"
  }
}


resource "aws_s3_bucket" "yes_policy" {
  bucket = "frontend-access-logs"
  acl    = "private"

  versioning {
    enabled = true
  }

  logging {
    target_bucket = "log-bucket"
    target_prefix = "AWSLogs/frontend-lb-access-logs/"
  }
}

resource "aws_s3_bucket_policy" "frontend_lb_logs_policy" {
  bucket = aws_s3_bucket.yes_policy.id

  policy = jsonencode({
    Version = "2012-10-17"
    Id      = "MYBUCKETPOLICY"
    Statement = [
      {
        Sid       = "IPAllow"
        Effect    = "Deny"
        Principal = "*"
        Action    = "s3:*"
        Resource = [
          aws_s3_bucket.b.arn,
          "${aws_s3_bucket.b.arn}/*",
        ]
        Condition = {
          IpAddress = {
            "aws:SourceIp" = "8.8.8.8/32"
          }
        }
      },
    ]
  })
}

@gaurav-gogia gaurav-gogia added the policy Issue concerning policy maintainers. label May 31, 2021
@gaurav-gogia gaurav-gogia self-assigned this May 31, 2021
@sonarcloud
Copy link

sonarcloud bot commented May 31, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@gaurav-gogia gaurav-gogia changed the title bucket policy check false positive fix aws s3 policy s3EnforceUserAcl update May 31, 2021
@codecov
Copy link

codecov bot commented May 31, 2021

Codecov Report

Merging #828 (81e1b2b) into master (0ed8ef7) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #828   +/-   ##
=======================================
  Coverage   74.99%   74.99%           
=======================================
  Files         113      113           
  Lines        3463     3463           
=======================================
  Hits         2597     2597           
  Misses        675      675           
  Partials      191      191           

Copy link
Contributor

@shreyas-phansalkar-189 shreyas-phansalkar-189 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approved it.

@gaurav-gogia gaurav-gogia merged commit 971845a into tenable:master Jun 2, 2021
@gaurav-gogia gaurav-gogia deleted the bugfix/s3_enforce_acl branch June 3, 2021 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
policy Issue concerning policy maintainers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Valid Terraform configuration fails with s3EnforceUserAcl
2 participants