Commit 0d96e805 authored by Anton Babenko's avatar Anton Babenko

Updated example to show bucket policy usage

parent 7fe89270
locals {
bucket_name = "s3-bucket-${random_pet.this.id}"
}
resource "random_pet" "this" { resource "random_pet" "this" {
length = 2 length = 2
} }
...@@ -16,12 +20,29 @@ module "log_bucket" { ...@@ -16,12 +20,29 @@ module "log_bucket" {
attach_elb_log_delivery_policy = true attach_elb_log_delivery_policy = true
} }
data "aws_iam_policy_document" "bucket_policy" {
statement {
principals {
type = "AWS"
identifiers = ["*"]
}
actions = [
"s3:ListBucket",
]
resources = [
"arn:aws:s3:::${local.bucket_name}",
]
}
}
module "s3_bucket" { module "s3_bucket" {
source = "../../" source = "../../"
bucket = "s3-bucket-${random_pet.this.id}" bucket = local.bucket_name
acl = "private" acl = "private"
force_destroy = true force_destroy = true
policy = data.aws_iam_policy_document.bucket_policy.json
tags = { tags = {
Owner = "Anton" Owner = "Anton"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment