Skip to content

Commit 6e25437

Browse files
kclindenKasey Lindenbryantbiggs
authored
feat: Add Cross Account Flow Support (#1014)
* feat: Add Cross Account Flow Support * fix: update flow log naming convention --------- Co-authored-by: Kasey Linden <[email protected]> Co-authored-by: Bryant Biggs <[email protected]>
1 parent 68105dc commit 6e25437

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,9 @@ No modules.
450450
| <a name="input_flow_log_cloudwatch_log_group_name_suffix"></a> [flow\_log\_cloudwatch\_log\_group\_name\_suffix](#input\_flow\_log\_cloudwatch\_log\_group\_name\_suffix) | Specifies the name suffix of CloudWatch Log Group for VPC flow logs | `string` | `""` | no |
451451
| <a name="input_flow_log_cloudwatch_log_group_retention_in_days"></a> [flow\_log\_cloudwatch\_log\_group\_retention\_in\_days](#input\_flow\_log\_cloudwatch\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group for VPC flow logs | `number` | `null` | no |
452452
| <a name="input_flow_log_cloudwatch_log_group_skip_destroy"></a> [flow\_log\_cloudwatch\_log\_group\_skip\_destroy](#input\_flow\_log\_cloudwatch\_log\_group\_skip\_destroy) | Set to true if you do not wish the log group (and any logs it may contain) to be deleted at destroy time, and instead just remove the log group from the Terraform state | `bool` | `false` | no |
453+
| <a name="input_flow_log_deliver_cross_account_role"></a> [flow\_log\_deliver\_cross\_account\_role](#input\_flow\_log\_deliver\_cross\_account\_role) | (Optional) ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts. | `string` | `null` | no |
453454
| <a name="input_flow_log_destination_arn"></a> [flow\_log\_destination\_arn](#input\_flow\_log\_destination\_arn) | The ARN of the CloudWatch log group or S3 bucket where VPC Flow Logs will be pushed. If this ARN is a S3 bucket the appropriate permissions need to be set on that bucket's policy. When create\_flow\_log\_cloudwatch\_log\_group is set to false this argument must be provided | `string` | `""` | no |
454-
| <a name="input_flow_log_destination_type"></a> [flow\_log\_destination\_type](#input\_flow\_log\_destination\_type) | Type of flow log destination. Can be s3 or cloud-watch-logs | `string` | `"cloud-watch-logs"` | no |
455+
| <a name="input_flow_log_destination_type"></a> [flow\_log\_destination\_type](#input\_flow\_log\_destination\_type) | Type of flow log destination. Can be s3, kinesis-data-firehose or cloud-watch-logs | `string` | `"cloud-watch-logs"` | no |
455456
| <a name="input_flow_log_file_format"></a> [flow\_log\_file\_format](#input\_flow\_log\_file\_format) | (Optional) The format for the flow log. Valid values: `plain-text`, `parquet` | `string` | `null` | no |
456457
| <a name="input_flow_log_hive_compatible_partitions"></a> [flow\_log\_hive\_compatible\_partitions](#input\_flow\_log\_hive\_compatible\_partitions) | (Optional) Indicates whether to use Hive-compatible prefixes for flow logs stored in Amazon S3 | `bool` | `false` | no |
457458
| <a name="input_flow_log_log_format"></a> [flow\_log\_log\_format](#input\_flow\_log\_log\_format) | The fields to include in the flow log record, in the order in which they should appear | `string` | `null` | no |
@@ -682,6 +683,7 @@ No modules.
682683
| <a name="output_vpc_enable_dns_hostnames"></a> [vpc\_enable\_dns\_hostnames](#output\_vpc\_enable\_dns\_hostnames) | Whether or not the VPC has DNS hostname support |
683684
| <a name="output_vpc_enable_dns_support"></a> [vpc\_enable\_dns\_support](#output\_vpc\_enable\_dns\_support) | Whether or not the VPC has DNS support |
684685
| <a name="output_vpc_flow_log_cloudwatch_iam_role_arn"></a> [vpc\_flow\_log\_cloudwatch\_iam\_role\_arn](#output\_vpc\_flow\_log\_cloudwatch\_iam\_role\_arn) | The ARN of the IAM role used when pushing logs to Cloudwatch log group |
686+
| <a name="output_vpc_flow_log_deliver_cross_account_role"></a> [vpc\_flow\_log\_deliver\_cross\_account\_role](#output\_vpc\_flow\_log\_deliver\_cross\_account\_role) | The ARN of the IAM role used when pushing logs cross account |
685687
| <a name="output_vpc_flow_log_destination_arn"></a> [vpc\_flow\_log\_destination\_arn](#output\_vpc\_flow\_log\_destination\_arn) | The ARN of the destination for VPC Flow Logs |
686688
| <a name="output_vpc_flow_log_destination_type"></a> [vpc\_flow\_log\_destination\_type](#output\_vpc\_flow\_log\_destination\_type) | The type of the destination for VPC Flow Logs |
687689
| <a name="output_vpc_flow_log_id"></a> [vpc\_flow\_log\_id](#output\_vpc\_flow\_log\_id) | The ID of the Flow Log resource |

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ output "vpc_flow_log_cloudwatch_iam_role_arn" {
609609
value = local.flow_log_iam_role_arn
610610
}
611611

612+
output "vpc_flow_log_deliver_cross_account_role" {
613+
description = "The ARN of the IAM role used when pushing logs cross account"
614+
value = try(aws_flow_log.this[0].deliver_cross_account_role, null)
615+
}
616+
612617
################################################################################
613618
# Static values (arguments)
614619
################################################################################

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ variable "flow_log_traffic_type" {
14851485
}
14861486

14871487
variable "flow_log_destination_type" {
1488-
description = "Type of flow log destination. Can be s3 or cloud-watch-logs"
1488+
description = "Type of flow log destination. Can be s3, kinesis-data-firehose or cloud-watch-logs"
14891489
type = string
14901490
default = "cloud-watch-logs"
14911491
}
@@ -1502,6 +1502,12 @@ variable "flow_log_destination_arn" {
15021502
default = ""
15031503
}
15041504

1505+
variable "flow_log_deliver_cross_account_role" {
1506+
description = "(Optional) ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts."
1507+
type = string
1508+
default = null
1509+
}
1510+
15051511
variable "flow_log_file_format" {
15061512
description = "(Optional) The format for the flow log. Valid values: `plain-text`, `parquet`"
15071513
type = string

vpc-flow-logs.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ locals {
1717
resource "aws_flow_log" "this" {
1818
count = local.enable_flow_log ? 1 : 0
1919

20-
log_destination_type = var.flow_log_destination_type
21-
log_destination = local.flow_log_destination_arn
22-
log_format = var.flow_log_log_format
23-
iam_role_arn = local.flow_log_iam_role_arn
24-
traffic_type = var.flow_log_traffic_type
25-
vpc_id = local.vpc_id
26-
max_aggregation_interval = var.flow_log_max_aggregation_interval
20+
log_destination_type = var.flow_log_destination_type
21+
log_destination = local.flow_log_destination_arn
22+
log_format = var.flow_log_log_format
23+
iam_role_arn = local.flow_log_iam_role_arn
24+
deliver_cross_account_role = var.flow_log_deliver_cross_account_role
25+
traffic_type = var.flow_log_traffic_type
26+
vpc_id = local.vpc_id
27+
max_aggregation_interval = var.flow_log_max_aggregation_interval
2728

2829
dynamic "destination_options" {
2930
for_each = var.flow_log_destination_type == "s3" ? [true] : []

0 commit comments

Comments
 (0)