Skip to content

blackbird-cloud/terraform-aws-s3-bucket-policy

Repository files navigation

Terraform Aws S3 Bucket Policy Module

Terraform module to create an AWS S3 bucket policy

blackbird-logo

Example

data "aws_caller_identity" "current" {}

module "s3_bucket_policy" {
  source  = "blackbird-cloud/s3-bucket-policy/aws"
  version = "~> 0"

  s3_bucket_id = "mybucketid"
  policy       = <<EOF
  {
  "Version": "2012-10-17",
  "Statement": [
    {
        "Sid": "Allow source account access to the bucket",
        "Effect": "Allow",
        "Principal": {
          "AWS": "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"
        },
        "Action": "s3:*",
        "Resource": [
          "arn:aws:s3:::mybucketid",
          "arn:aws:s3:::mybucketid/*"
        ]
    }
  ]
}
  EOF
}

Requirements

Name Version
terraform >= 1
aws >= 3

Providers

Name Version
aws >= 3

Resources

Name Type
aws_s3_bucket_policy.bucket resource
aws_caller_identity.current data source
aws_elb_service_account.this data source
aws_iam_policy_document.combined data source
aws_iam_policy_document.deny_insecure_transport data source
aws_iam_policy_document.elb_log_delivery data source
aws_iam_policy_document.lb_log_delivery data source
aws_iam_policy_document.require_latest_tls data source
aws_s3_bucket.selected data source

Inputs

Name Description Type Default Required
attach_deny_insecure_transport_policy Attach a policy that will deny requests that have no secure transport. bool true no
attach_elb_log_delivery_policy attach_elb_log_delivery_policy bool false no
attach_lb_log_delivery_policy attach_lb_log_delivery_policy bool false no
attach_require_latest_tls_policy Attach a policy that will deny requests that use a TLS version lower then 1.2. bool true no
policy The fully-formed AWS policy as JSON for the S3 bucket access policy string null no
s3_bucket_id The name of the bucket. string n/a yes

Outputs

Name Description
policy The applied S3 bucket policy.

About

We are Blackbird Cloud, Amsterdam based cloud consultancy, and cloud management service provider. We help companies build secure, cost efficient, and scale-able solutions.

Checkout our other 👉 terraform modules

Copyright

Copyright © 2017-2024 Blackbird Cloud