-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from QuiNovas/develop
First checkin
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# terraform-aws-lambda-functions-bucket | ||
|
||
This module creates a bucket for log storage, including from other S3 buckets | ||
|
||
## Authors | ||
|
||
Module managed by Quinovas (https://github.com/QuiNovas) | ||
|
||
## License | ||
|
||
Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/). See LICENSE for full details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
resource "aws_s3_bucket" "log" { | ||
bucket = "${var.name_prefix}-log" | ||
acl = "log-delivery-write" | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
lifecycle_rule { | ||
id = "log" | ||
prefix = "/" | ||
enabled = true | ||
|
||
transition { | ||
days = 30 | ||
storage_class = "GLACIER" | ||
} | ||
|
||
expiration { | ||
days = 2555 | ||
} | ||
} | ||
} | ||
|
||
data "aws_elb_service_account" "main" {} | ||
|
||
data "aws_iam_policy_document" "log" { | ||
|
||
statement { | ||
actions = [ | ||
"s3:PutObject" | ||
] | ||
principals { | ||
identifiers = [ | ||
"${data.aws_elb_service_account.main.arn}" | ||
] | ||
type = "AWS" | ||
} | ||
resources = [ | ||
"${aws_s3_bucket.log.arn}/elb/*" | ||
] | ||
sid = "EnableELBLogging" | ||
} | ||
|
||
statement { | ||
actions = [ | ||
"s3:*" | ||
] | ||
condition { | ||
test = "Bool" | ||
values = [ | ||
"false" | ||
] | ||
variable = "aws:SecureTransport" | ||
} | ||
effect = "Deny" | ||
principals { | ||
identifiers = [ | ||
"*" | ||
] | ||
type = "AWS" | ||
} | ||
resources = [ | ||
"${aws_s3_bucket.log.arn}", | ||
"${aws_s3_bucket.log.arn}/*" | ||
] | ||
sid = "DenyUnsecuredTransport" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_policy" "log" { | ||
bucket = "${aws_s3_bucket.log.id}" | ||
policy = "${data.aws_iam_policy_document.log.json}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "arn" { | ||
description = "The ARN of the bucket. Will be of format arn:aws:s3:::bucketname." | ||
value = "${aws_s3_bucket.log.arn}" | ||
} | ||
|
||
output "id" { | ||
description = "The name of the bucket." | ||
value = "${aws_s3_bucket.log.id}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variable "name_prefix" { | ||
description = "The name prefix to use when creating resource names" | ||
type = "string" | ||
} |