Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tf_mod_aws_elb
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
steamhaus
tf_mod_aws_elb
Commits
487e5be1
Commit
487e5be1
authored
Aug 14, 2018
by
Adrian Horrocks
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'elb-logs-to-s3' into 'master'
Elb logs to s3 See merge request
!3
parents
3a4f81b5
8f11e255
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
README.md
README.md
+1
-1
main.tf
main.tf
+53
-0
No files found.
README.md
View file @
487e5be1
main.tf
View file @
487e5be1
...
...
@@ -67,6 +67,14 @@ variable "health_check_interval" {
default
=
"30"
}
variable
"logs_enabled"
{
default
=
"false"
}
variable
"logs_interval"
{
default
=
"5"
}
#############################################################################################################
# Security Group
#############################################################################################################
...
...
@@ -129,6 +137,12 @@ resource "aws_elb" "main" {
instance_protocol
=
"
${
var
.
service_protocol
}
"
}
access_logs
{
enabled
=
"
${
var
.
logs_enabled
}
"
bucket
=
"
${
var
.
name
}
-
${
random_string
.
bucket_name
.
result
}
-elb-logs"
interval
=
"
${
var
.
logs_interval
}
"
}
health_check
{
healthy_threshold
=
"
${
var
.
health_check_healthy_threshold
}
"
unhealthy_threshold
=
"
${
var
.
health_check_unhealthy_threshold
}
"
...
...
@@ -138,6 +152,45 @@ resource "aws_elb" "main" {
}
}
#############################################################################################################
# S3 Bucket for Log Exports
#############################################################################################################
resource
"random_string"
"bucket_name"
{
length
=
8
special
=
false
upper
=
false
}
data
"aws_elb_service_account"
"main"
{}
resource
"aws_s3_bucket"
"elb_logs"
{
count
=
"
${
var
.
logs_enabled
==
"true"
?
1
:
0
}
"
bucket
=
"
${
var
.
name
}
-
${
random_string
.
bucket_name
.
result
}
-elb-logs"
acl
=
"private"
policy
=
<<
POLICY
{
"Id": "Policy",
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::${var.name}-${random_string.bucket_name.result}-elb-logs/AWSLogs/*",
"Principal": {
"AWS": [
"${data.aws_elb_service_account.main.arn}"
]
}
}
]
}
POLICY
}
#############################################################################################################
# Outputs
#############################################################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment