-
-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disabled logging now possible #69
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,14 @@ | |
# See http://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: git://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.7.0 | ||
rev: v1.7.1 | ||
sha: 091f8b15d7b458e5a0aca642483deb2205e7db02 | ||
hooks: | ||
- id: terraform_fmt | ||
- id: terraform_docs | ||
# - id: terraform_docs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you disable this hook it won't update documentation automatically. Not sure you want this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hook failed for me and I was somewhat surprised at what it was requiring. I've documented in the readme how I'm accustomed to running this tool, packing all the docs in Obviously it's your repo and project to do what you want with it but if it were mine, I'd probably try to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The primary feature of pre-commit hooks is that developers who push PR or maintainers like you and me get them installed once and forget. The code is automatically formatted, the documentation is updated once a change is being committed - as a result, documentation is along with the code in the same PR. It also simplifies manual steps like you have to do now during release. I don't have strong objections if you prefer to do it another way, absolutely :) |
||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v1.2.3 | ||
sha: 92e1570c282e3c69a1f8b5b8dd8d286fe27cfaa7 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: trailing-whitespace | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
resource "aws_lb" "application_no_logs" { | ||
load_balancer_type = "application" | ||
name = "${var.load_balancer_name}" | ||
internal = "${var.load_balancer_is_internal}" | ||
security_groups = ["${var.security_groups}"] | ||
subnets = ["${var.subnets}"] | ||
idle_timeout = "${var.idle_timeout}" | ||
enable_deletion_protection = "${var.enable_deletion_protection}" | ||
enable_http2 = "${var.enable_http2}" | ||
ip_address_type = "${var.ip_address_type}" | ||
tags = "${merge(var.tags, map("Name", var.load_balancer_name))}" | ||
|
||
timeouts { | ||
create = "${var.load_balancer_create_timeout}" | ||
delete = "${var.load_balancer_delete_timeout}" | ||
update = "${var.load_balancer_update_timeout}" | ||
} | ||
|
||
count = "${var.logging_enabled ? 0 : 1}" | ||
} | ||
|
||
resource "aws_lb_target_group" "main_no_logs" { | ||
name = "${lookup(var.target_groups[count.index], "name")}" | ||
vpc_id = "${var.vpc_id}" | ||
port = "${lookup(var.target_groups[count.index], "backend_port")}" | ||
protocol = "${upper(lookup(var.target_groups[count.index], "backend_protocol"))}" | ||
deregistration_delay = "${lookup(var.target_groups[count.index], "deregistration_delay", lookup(var.target_groups_defaults, "deregistration_delay"))}" | ||
target_type = "${lookup(var.target_groups[count.index], "target_type", lookup(var.target_groups_defaults, "target_type"))}" | ||
|
||
health_check { | ||
interval = "${lookup(var.target_groups[count.index], "health_check_interval", lookup(var.target_groups_defaults, "health_check_interval"))}" | ||
path = "${lookup(var.target_groups[count.index], "health_check_path", lookup(var.target_groups_defaults, "health_check_path"))}" | ||
port = "${lookup(var.target_groups[count.index], "health_check_port", lookup(var.target_groups_defaults, "health_check_port"))}" | ||
healthy_threshold = "${lookup(var.target_groups[count.index], "health_check_healthy_threshold", lookup(var.target_groups_defaults, "health_check_healthy_threshold"))}" | ||
unhealthy_threshold = "${lookup(var.target_groups[count.index], "health_check_unhealthy_threshold", lookup(var.target_groups_defaults, "health_check_unhealthy_threshold"))}" | ||
timeout = "${lookup(var.target_groups[count.index], "health_check_timeout", lookup(var.target_groups_defaults, "health_check_timeout"))}" | ||
protocol = "${upper(lookup(var.target_groups[count.index], "healthcheck_protocol", lookup(var.target_groups[count.index], "backend_protocol")))}" | ||
matcher = "${lookup(var.target_groups[count.index], "health_check_matcher", lookup(var.target_groups_defaults, "health_check_matcher"))}" | ||
} | ||
|
||
stickiness { | ||
type = "lb_cookie" | ||
cookie_duration = "${lookup(var.target_groups[count.index], "cookie_duration", lookup(var.target_groups_defaults, "cookie_duration"))}" | ||
enabled = "${lookup(var.target_groups[count.index], "stickiness_enabled", lookup(var.target_groups_defaults, "stickiness_enabled"))}" | ||
} | ||
|
||
tags = "${merge(var.tags, map("Name", lookup(var.target_groups[count.index], "name")))}" | ||
count = "${var.logging_enabled ? 0 : var.target_groups_count}" | ||
depends_on = ["aws_lb.application_no_logs"] | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_lb_listener" "frontend_http_tcp_no_logs" { | ||
load_balancer_arn = "${element(concat(aws_lb.application_no_logs.*.arn, list("")), 0)}" | ||
port = "${lookup(var.http_tcp_listeners[count.index], "port")}" | ||
protocol = "${lookup(var.http_tcp_listeners[count.index], "protocol")}" | ||
count = "${var.logging_enabled ? 0 : var.http_tcp_listeners_count}" | ||
|
||
default_action { | ||
target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", 0)]}" | ||
type = "forward" | ||
} | ||
} | ||
|
||
resource "aws_lb_listener" "frontend_https_no_logs" { | ||
load_balancer_arn = "${element(concat(aws_lb.application_no_logs.*.arn, list("")), 0)}" | ||
port = "${lookup(var.https_listeners[count.index], "port")}" | ||
protocol = "HTTPS" | ||
certificate_arn = "${lookup(var.https_listeners[count.index], "certificate_arn")}" | ||
ssl_policy = "${lookup(var.https_listeners[count.index], "ssl_policy", var.listener_ssl_policy_default)}" | ||
count = "${var.logging_enabled ? 0 : var.https_listeners_count}" | ||
|
||
default_action { | ||
target_group_arn = "${aws_lb_target_group.main_no_logs.*.id[lookup(var.https_listeners[count.index], "target_group_index", 0)]}" | ||
type = "forward" | ||
} | ||
} | ||
|
||
resource "aws_lb_listener_certificate" "https_listener_no_logs" { | ||
listener_arn = "${aws_lb_listener.frontend_https_no_logs.*.arn[lookup(var.extra_ssl_certs[count.index], "https_listener_index")]}" | ||
certificate_arn = "${lookup(var.extra_ssl_certs[count.index], "certificate_arn")}" | ||
count = "${var.logging_enabled ? 0 : var.extra_ssl_certs_count}" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
resource "aws_lb" "application" { | ||
load_balancer_type = "application" | ||
name = "${var.load_balancer_name}" | ||
internal = "${var.load_balancer_is_internal}" | ||
security_groups = ["${var.security_groups}"] | ||
subnets = ["${var.subnets}"] | ||
idle_timeout = "${var.idle_timeout}" | ||
enable_deletion_protection = "${var.enable_deletion_protection}" | ||
enable_http2 = "${var.enable_http2}" | ||
ip_address_type = "${var.ip_address_type}" | ||
tags = "${merge(var.tags, map("Name", var.load_balancer_name))}" | ||
|
||
access_logs { | ||
enabled = true | ||
bucket = "${var.log_bucket_name}" | ||
prefix = "${var.log_location_prefix}" | ||
} | ||
|
||
timeouts { | ||
create = "${var.load_balancer_create_timeout}" | ||
delete = "${var.load_balancer_delete_timeout}" | ||
update = "${var.load_balancer_update_timeout}" | ||
} | ||
|
||
count = "${var.logging_enabled ? 1 : 0}" | ||
} | ||
|
||
resource "aws_lb_target_group" "main" { | ||
name = "${lookup(var.target_groups[count.index], "name")}" | ||
vpc_id = "${var.vpc_id}" | ||
port = "${lookup(var.target_groups[count.index], "backend_port")}" | ||
protocol = "${upper(lookup(var.target_groups[count.index], "backend_protocol"))}" | ||
deregistration_delay = "${lookup(var.target_groups[count.index], "deregistration_delay", lookup(var.target_groups_defaults, "deregistration_delay"))}" | ||
target_type = "${lookup(var.target_groups[count.index], "target_type", lookup(var.target_groups_defaults, "target_type"))}" | ||
|
||
health_check { | ||
interval = "${lookup(var.target_groups[count.index], "health_check_interval", lookup(var.target_groups_defaults, "health_check_interval"))}" | ||
path = "${lookup(var.target_groups[count.index], "health_check_path", lookup(var.target_groups_defaults, "health_check_path"))}" | ||
port = "${lookup(var.target_groups[count.index], "health_check_port", lookup(var.target_groups_defaults, "health_check_port"))}" | ||
healthy_threshold = "${lookup(var.target_groups[count.index], "health_check_healthy_threshold", lookup(var.target_groups_defaults, "health_check_healthy_threshold"))}" | ||
unhealthy_threshold = "${lookup(var.target_groups[count.index], "health_check_unhealthy_threshold", lookup(var.target_groups_defaults, "health_check_unhealthy_threshold"))}" | ||
timeout = "${lookup(var.target_groups[count.index], "health_check_timeout", lookup(var.target_groups_defaults, "health_check_timeout"))}" | ||
protocol = "${upper(lookup(var.target_groups[count.index], "healthcheck_protocol", lookup(var.target_groups[count.index], "backend_protocol")))}" | ||
matcher = "${lookup(var.target_groups[count.index], "health_check_matcher", lookup(var.target_groups_defaults, "health_check_matcher"))}" | ||
} | ||
|
||
stickiness { | ||
type = "lb_cookie" | ||
cookie_duration = "${lookup(var.target_groups[count.index], "cookie_duration", lookup(var.target_groups_defaults, "cookie_duration"))}" | ||
enabled = "${lookup(var.target_groups[count.index], "stickiness_enabled", lookup(var.target_groups_defaults, "stickiness_enabled"))}" | ||
} | ||
|
||
tags = "${merge(var.tags, map("Name", lookup(var.target_groups[count.index], "name")))}" | ||
count = "${var.logging_enabled ? var.target_groups_count : 0}" | ||
depends_on = ["aws_lb.application"] | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_lb_listener" "frontend_http_tcp" { | ||
load_balancer_arn = "${element(concat(aws_lb.application.*.arn, aws_lb.application_no_logs.*.arn), 0)}" | ||
port = "${lookup(var.http_tcp_listeners[count.index], "port")}" | ||
protocol = "${lookup(var.http_tcp_listeners[count.index], "protocol")}" | ||
count = "${var.logging_enabled ? var.http_tcp_listeners_count : 0}" | ||
|
||
default_action { | ||
target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.http_tcp_listeners[count.index], "target_group_index", 0)]}" | ||
type = "forward" | ||
} | ||
} | ||
|
||
resource "aws_lb_listener" "frontend_https" { | ||
load_balancer_arn = "${element(concat(aws_lb.application.*.arn, aws_lb.application_no_logs.*.arn), 0)}" | ||
port = "${lookup(var.https_listeners[count.index], "port")}" | ||
protocol = "HTTPS" | ||
certificate_arn = "${lookup(var.https_listeners[count.index], "certificate_arn")}" | ||
ssl_policy = "${lookup(var.https_listeners[count.index], "ssl_policy", var.listener_ssl_policy_default)}" | ||
count = "${var.logging_enabled ? var.https_listeners_count : 0}" | ||
|
||
default_action { | ||
target_group_arn = "${aws_lb_target_group.main.*.id[lookup(var.https_listeners[count.index], "target_group_index", 0)]}" | ||
type = "forward" | ||
} | ||
} | ||
|
||
resource "aws_lb_listener_certificate" "https_listener" { | ||
listener_arn = "${aws_lb_listener.frontend_https.*.arn[lookup(var.extra_ssl_certs[count.index], "https_listener_index")]}" | ||
certificate_arn = "${lookup(var.extra_ssl_certs[count.index], "certificate_arn")}" | ||
count = "${var.logging_enabled ? var.extra_ssl_certs_count : 0}" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can run
pre-commit autoupdate
to get it updated.sha
is not required.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm maybe my
pre-commit
is out of date. It was upset at me. Will update.