Skip to content

Commit 220e3c5

Browse files
committed
[#316] Separate data and local into individual files
1 parent 39e5f29 commit 220e3c5

File tree

3 files changed

+57
-59
lines changed

3 files changed

+57
-59
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "aws_caller_identity" "current" {}
2+
data "aws_partition" "current" {}
3+
data "aws_region" "current" {}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
locals {
2+
ordered_partition_keys = [
3+
{ key = "aws_account_id", value = "string" },
4+
{ key = "aws_service", value = "string" },
5+
{ key = "aws_region", value = "string" },
6+
{ key = "year", value = "string" },
7+
{ key = "month", value = "string" },
8+
{ key = "day", value = "string" },
9+
{ key = "hour", value = "string" }
10+
]
11+
12+
//https://docs.aws.amazon.com/vpc/latest/userguide/flow-log-records.html#flow-logs-fields
13+
ordered_table_columns = [
14+
{ key = "version", value = "int" },
15+
{ key = "account_id", value = "string" },
16+
{ key = "action", value = "string" },
17+
{ key = "interface_id", value = "string" },
18+
{ key = "srcaddr", value = "string" },
19+
{ key = "dstaddr", value = "string" },
20+
{ key = "srcport", value = "int" },
21+
{ key = "dstport", value = "int" },
22+
{ key = "protocol", value = "int" },
23+
{ key = "packets", value = "bigint" },
24+
{ key = "bytes", value = "bigint" },
25+
{ key = "start", value = "bigint" },
26+
{ key = "end", value = "bigint" },
27+
{ key = "log_status", value = "string" },
28+
{ key = "vpc_id", value = "string" },
29+
{ key = "subnet_id", value = "string" },
30+
{ key = "instance_id", value = "string" },
31+
{ key = "tcp_flags", value = "int" },
32+
{ key = "type", value = "string" },
33+
{ key = "pkt_srcaddr", value = "string" },
34+
{ key = "pkt_dstaddr", value = "string" },
35+
{ key = "region", value = "string" },
36+
{ key = "az_id", value = "string" },
37+
{ key = "sublocation_type", value = "string" },
38+
{ key = "sublocation_id", value = "string" },
39+
{ key = "pkt_src_aws_service", value = "string" },
40+
{ key = "pkt_dst_aws_service", value = "string" },
41+
{ key = "flow_direction", value = "string" },
42+
{ key = "traffic_path", value = "int" },
43+
{ key = "ecs_task_id", value = "string" },
44+
{ key = "reject_reason", value = "string" },
45+
]
46+
47+
log_format = join(
48+
" ",
49+
[
50+
for col in local.ordered_table_columns :
51+
"$${${replace(col.key, "_", "-")}}"
52+
]
53+
)
54+
}

templates/addons/aws/modules/vpc_flow_log/main.tf

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,3 @@
1-
data "aws_caller_identity" "current" {}
2-
data "aws_partition" "current" {}
3-
data "aws_region" "current" {}
4-
5-
locals {
6-
ordered_partition_keys = [
7-
{ key = "aws_account_id", value = "string" },
8-
{ key = "aws_service", value = "string" },
9-
{ key = "aws_region", value = "string" },
10-
{ key = "year", value = "string" },
11-
{ key = "month", value = "string" },
12-
{ key = "day", value = "string" },
13-
{ key = "hour", value = "string" }
14-
]
15-
16-
//https://docs.aws.amazon.com/vpc/latest/userguide/flow-log-records.html#flow-logs-fields
17-
ordered_table_columns = [
18-
{ key = "version", value = "int" },
19-
{ key = "account_id", value = "string" },
20-
{ key = "action", value = "string" },
21-
{ key = "interface_id", value = "string" },
22-
{ key = "srcaddr", value = "string" },
23-
{ key = "dstaddr", value = "string" },
24-
{ key = "srcport", value = "int" },
25-
{ key = "dstport", value = "int" },
26-
{ key = "protocol", value = "int" },
27-
{ key = "packets", value = "bigint" },
28-
{ key = "bytes", value = "bigint" },
29-
{ key = "start", value = "bigint" },
30-
{ key = "end", value = "bigint" },
31-
{ key = "log_status", value = "string" },
32-
{ key = "vpc_id", value = "string" },
33-
{ key = "subnet_id", value = "string" },
34-
{ key = "instance_id", value = "string" },
35-
{ key = "tcp_flags", value = "int" },
36-
{ key = "type", value = "string" },
37-
{ key = "pkt_srcaddr", value = "string" },
38-
{ key = "pkt_dstaddr", value = "string" },
39-
{ key = "region", value = "string" },
40-
{ key = "az_id", value = "string" },
41-
{ key = "sublocation_type", value = "string" },
42-
{ key = "sublocation_id", value = "string" },
43-
{ key = "pkt_src_aws_service", value = "string" },
44-
{ key = "pkt_dst_aws_service", value = "string" },
45-
{ key = "flow_direction", value = "string" },
46-
{ key = "traffic_path", value = "int" },
47-
{ key = "ecs_task_id", value = "string" },
48-
{ key = "reject_reason", value = "string" },
49-
]
50-
51-
log_format = join(
52-
" ",
53-
[
54-
for col in local.ordered_table_columns :
55-
"$${${replace(col.key, "_", "-")}}"
56-
]
57-
)
58-
}
59-
601
# S3 Bucket for VPC Flow Logs
612
# trivy:ignore:AVD-AWS-0088 S3 Buckets should be encrypted to protect the data that is stored within them if access is compromised.
623
# trivy:ignore:AVD-AWS-0132 S3 Encryption using AWS keys provides protection for your S3 buckets. To increase control of the encryption and manage factors like rotation use customer managed keys.

0 commit comments

Comments
 (0)