File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,28 @@ resource "aws_lb" "this" {
15
15
preserve_host_header = var. preserve_host_header
16
16
enable_deletion_protection = var. enable_deletion_protection
17
17
18
+ dynamic "access_logs" {
19
+ for_each = var. access_logs != null ? [var . access_logs ] : []
20
+ iterator = access_log
21
+
22
+ content {
23
+ bucket = access_log. value . bucket
24
+ enabled = access_log. value . enabled
25
+ prefix = access_log. value . prefix
26
+ }
27
+ }
28
+
29
+ dynamic "connection_logs" {
30
+ for_each = var. connection_logs != null ? [var . connection_logs ] : []
31
+ iterator = connection_log
32
+
33
+ content {
34
+ bucket = connection_log. value . bucket
35
+ enabled = connection_log. value . enabled
36
+ prefix = connection_log. value . prefix
37
+ }
38
+ }
39
+
18
40
tags = var. tags
19
41
}
20
42
Original file line number Diff line number Diff line change @@ -37,6 +37,26 @@ variable "enable_deletion_protection" {
37
37
default = false
38
38
}
39
39
40
+ variable "access_logs" {
41
+ description = " (Optional) Access Logs block."
42
+ type = object ({
43
+ bucket = string
44
+ enabled = optional (bool , true )
45
+ prefix = optional (string , null )
46
+ })
47
+ default = null
48
+ }
49
+
50
+ variable "connection_logs" {
51
+ description = " (Optional) Connection Logs block."
52
+ type = object ({
53
+ bucket = string
54
+ enabled = optional (bool , false )
55
+ prefix = optional (string , null )
56
+ })
57
+ default = null
58
+ }
59
+
40
60
variable "tags" {
41
61
description = " (Optional) Map of tags to assign to the resource."
42
62
type = map (string )
Original file line number Diff line number Diff line change @@ -21,6 +21,18 @@ run "lb_attributes_match" {
21
21
preserve_host_header = true
22
22
enable_deletion_protection = true
23
23
24
+ access_logs = {
25
+ bucket = " example-access-logs-bucket"
26
+ enabled = true
27
+ prefix = " example-access-logs-bucket-prefix"
28
+ }
29
+
30
+ connection_logs = {
31
+ bucket = " example-connection-logs-bucket"
32
+ enabled = true
33
+ prefix = " example-connection-logs-bucket-prefix"
34
+ }
35
+
24
36
listeners = {}
25
37
26
38
tags = {
@@ -57,6 +69,16 @@ run "lb_attributes_match" {
57
69
error_message = " Enable deletion protection mismatch"
58
70
}
59
71
72
+ assert {
73
+ condition = aws_lb. this . access_logs [0 ] == var. access_logs
74
+ error_message = " Access logs mismatch"
75
+ }
76
+
77
+ assert {
78
+ condition = aws_lb. this . connection_logs [0 ] == var. connection_logs
79
+ error_message = " Connection logs mismatch"
80
+ }
81
+
60
82
assert {
61
83
condition = aws_lb. this . tags == var. tags
62
84
error_message = " Tags mismatch"
You can’t perform that action at this time.
0 commit comments