Skip to content

Commit b63322c

Browse files
benjaminvalienteBenjamin Valiente (Contractor)github-actions[bot]
authored
feat: adding retention support to Cloudwatch log group (#266)
* feat: adding retention support to Cloudwatch log group * terraform-docs: automated action --------- Co-authored-by: Benjamin Valiente (Contractor) <benjamin.valiente@thoughtbot.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent f2118c3 commit b63322c

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

aws/network/modules/vpc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Module for creating a VPC in AWS.
3636
| <a name="input_cidr_block"></a> [cidr\_block](#input\_cidr\_block) | CIDR block to be used for the VPC, such as 10.0.0.0/16 | `string` | n/a | yes |
3737
| <a name="input_enable_flow_logs"></a> [enable\_flow\_logs](#input\_enable\_flow\_logs) | Set to true to enable VPC flow logs | `bool` | `false` | no |
3838
| <a name="input_enable_ipv6"></a> [enable\_ipv6](#input\_enable\_ipv6) | Set to false to disable IPV6 | `bool` | `false` | no |
39+
| <a name="input_flow_logs_retention_days"></a> [flow\_logs\_retention\_days](#input\_flow\_logs\_retention\_days) | Number of days to retain VPC Flow Logs in CloudWatch. | `number` | `null` | no |
3940
| <a name="input_name"></a> [name](#input\_name) | Name for this network | `string` | n/a | yes |
4041
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Prefix to be applied to created resources | `list(string)` | `[]` | no |
4142
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to be applied to created resources | `map(string)` | `{}` | no |

aws/network/modules/vpc/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ data "aws_iam_policy_document" "flow_logs" {
6969
resource "aws_cloudwatch_log_group" "flow_logs" {
7070
count = var.enable_flow_logs ? 1 : 0
7171

72-
name = join("/", concat([""], var.namespace, [var.name, "flow-logs"]))
72+
name = join("/", concat([""], var.namespace, [var.name, "flow-logs"]))
73+
retention_in_days = var.flow_logs_retention_days
7374
}

aws/network/modules/vpc/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ variable "cidr_block" {
3131
type = string
3232
description = "CIDR block to be used for the VPC, such as 10.0.0.0/16"
3333
}
34+
35+
variable "flow_logs_retention_days" {
36+
description = "Number of days to retain VPC Flow Logs in CloudWatch." # Only applies when enable_flow_logs is true.
37+
type = number
38+
default = null # null = retain forever
39+
}

0 commit comments

Comments
 (0)