-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terraform): support scanning of Terraform managed modules instea…
…d of downloading them (#5635) * support scanning of Terraform managed modules instead of downloading them * add missing files and docs
- Loading branch information
Showing
13 changed files
with
292 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...le_loading/data/tf_managed_modules/.terraform/modules/log_group/modules/log-group/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "aws_cloudwatch_log_group" "this" { | ||
count = var.create ? 1 : 0 | ||
|
||
name = var.name | ||
name_prefix = var.name_prefix | ||
retention_in_days = var.retention_in_days | ||
kms_key_id = var.kms_key_id | ||
|
||
tags = var.tags | ||
} |
9 changes: 9 additions & 0 deletions
9
...loading/data/tf_managed_modules/.terraform/modules/log_group/modules/log-group/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "cloudwatch_log_group_name" { | ||
description = "Name of Cloudwatch log group" | ||
value = try(aws_cloudwatch_log_group.this[0].name, "") | ||
} | ||
|
||
output "cloudwatch_log_group_arn" { | ||
description = "ARN of Cloudwatch log group" | ||
value = try(aws_cloudwatch_log_group.this[0].arn, "") | ||
} |
40 changes: 40 additions & 0 deletions
40
...ading/data/tf_managed_modules/.terraform/modules/log_group/modules/log-group/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
variable "create" { | ||
description = "Whether to create the Cloudwatch log group" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "name" { | ||
description = "A name for the log group" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "name_prefix" { | ||
description = "A name prefix for the log group" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "retention_in_days" { | ||
description = "Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653." | ||
type = number | ||
default = null | ||
|
||
validation { | ||
condition = var.retention_in_days == null ? true : contains([0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653], var.retention_in_days) | ||
error_message = "Must be 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653 or 0 (zero indicates never expire logs)." | ||
} | ||
} | ||
|
||
variable "kms_key_id" { | ||
description = "The ARN of the KMS Key to use when encrypting logs" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "tags" { | ||
description = "A map of tags to add to Cloudwatch log group" | ||
type = map(string) | ||
default = {} | ||
} |
10 changes: 10 additions & 0 deletions
10
...oading/data/tf_managed_modules/.terraform/modules/log_group/modules/log-group/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.0" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/terraform/module_loading/data/tf_managed_modules/.terraform/modules/modules.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Modules": [ | ||
{ | ||
"Key": "log_group", | ||
"Source": "registry.terraform.io/terraform-aws-modules/cloudwatch/aws//modules/log-group", | ||
"Version": "4.1.0", | ||
"Dir": ".terraform/modules/log_group/modules/log-group" | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/terraform/module_loading/data/tf_managed_modules/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module "log_group" { | ||
source = "terraform-aws-modules/cloudwatch/aws//modules/log-group" | ||
|
||
name_prefix = "my-log-group-" | ||
retention_in_days = 7 | ||
} | ||
|
||
module "log_group_v4" { | ||
source = "terraform-aws-modules/cloudwatch/aws//modules/log-group" | ||
version = "~> 4.0" | ||
|
||
name_prefix = "my-log-group-" | ||
retention_in_days = 7 | ||
} |
Oops, something went wrong.