Skip to content

Commit

Permalink
Add ability to make s3 logger optionally. (#13)
Browse files Browse the repository at this point in the history
LGTM; Merging.
  • Loading branch information
marocchino authored and brandonjbjelland committed Sep 15, 2017
1 parent 1f1460c commit f933fa6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ For an example of using ALB with ECS look no further than the [hashicorp example
* `certificate_arn` - . (Required if using HTTPS in `alb_protocols`)
* `cookie_duration` - If sticky sessions via cookies are desired, set this variable to a value from 2 - 604800 seconds. (Optional)
* `health_check_path` - Path for the load balancer to health check instances. (Optional; default: /)
* `log_bucket` - S3 bucket where access logs should land. (Required)
* `log_prefix` - S3 prefix within the `log_bucket` where logs should land. (Optional)
* `log_bucket` - S3 bucket where access logs should land. If not set it will be not leave logs. (Optional; default: "")
* `log_prefix` - S3 prefix within the `log_bucket` where logs should land. (Optional; default: "")
* `principle_account_id` - A mapping of regions to principle account IDs used to send LB logs. (Should only change as regions are added)
* `subnets` - ALB will be created in the subnets in this list. (Required)
* `vpc_id` - Resources will be created in the VPC with this `id`. (Required)
Expand Down
6 changes: 4 additions & 2 deletions alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ resource "aws_alb" "main" {
internal = "${var.alb_is_internal}"

access_logs {
bucket = "${var.log_bucket}"
prefix = "${var.log_prefix}"
bucket = "${var.log_bucket}"
prefix = "${var.log_prefix}"
enabled = "${var.log_bucket != ""}"
}

tags = "${merge(var.tags, map("Name", format("%s", var.alb_name)))}"
}

resource "aws_s3_bucket" "log_bucket" {
count = "${var.log_bucket != "" ? 1 : 0}"
bucket = "${var.log_bucket}"
policy = "${data.template_file.bucket_policy.rendered}"
force_destroy = true
Expand Down
2 changes: 2 additions & 0 deletions alb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ variable "health_check_path" {

variable "log_bucket" {
description = "S3 bucket for storing ALB access logs."
default = ""
}

variable "log_prefix" {
description = "S3 prefix within the log_bucket under which logs are stored."
default = ""
}

variable "principle_account_id" {
Expand Down

0 comments on commit f933fa6

Please sign in to comment.