Skip to content

Commit 7256f7c

Browse files
authored
feat: Added support for CW log_group_class and skip_destroy (#565)
1 parent 73cd5bd commit 7256f7c

File tree

10 files changed

+82
-6
lines changed

10 files changed

+82
-6
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.88.4
3+
rev: v1.89.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each
@@ -24,7 +24,7 @@ repos:
2424
- "--args=--only=terraform_workspace_remote"
2525
- id: terraform_validate
2626
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: v4.5.0
27+
rev: v4.6.0
2828
hooks:
2929
- id: check-merge-conflict
3030
- id: end-of-file-fixer

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,9 @@ No modules.
756756
| <a name="input_authorization_type"></a> [authorization\_type](#input\_authorization\_type) | The type of authentication that the Lambda Function URL uses. Set to 'AWS\_IAM' to restrict access to authenticated IAM users only. Set to 'NONE' to bypass IAM authentication and create a public endpoint. | `string` | `"NONE"` | no |
757757
| <a name="input_build_in_docker"></a> [build\_in\_docker](#input\_build\_in\_docker) | Whether to build dependencies in Docker | `bool` | `false` | no |
758758
| <a name="input_cloudwatch_logs_kms_key_id"></a> [cloudwatch\_logs\_kms\_key\_id](#input\_cloudwatch\_logs\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data. | `string` | `null` | no |
759+
| <a name="input_cloudwatch_logs_log_group_class"></a> [cloudwatch\_logs\_log\_group\_class](#input\_cloudwatch\_logs\_log\_group\_class) | Specified the log class of the log group. Possible values are: `STANDARD` or `INFREQUENT_ACCESS` | `string` | `null` | no |
759760
| <a name="input_cloudwatch_logs_retention_in_days"></a> [cloudwatch\_logs\_retention\_in\_days](#input\_cloudwatch\_logs\_retention\_in\_days) | 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. | `number` | `null` | no |
761+
| <a name="input_cloudwatch_logs_skip_destroy"></a> [cloudwatch\_logs\_skip\_destroy](#input\_cloudwatch\_logs\_skip\_destroy) | Whether to keep the log group (and any logs it may contain) at destroy time. | `bool` | `false` | no |
760762
| <a name="input_cloudwatch_logs_tags"></a> [cloudwatch\_logs\_tags](#input\_cloudwatch\_logs\_tags) | A map of tags to assign to the resource. | `map(string)` | `{}` | no |
761763
| <a name="input_code_signing_config_arn"></a> [code\_signing\_config\_arn](#input\_code\_signing\_config\_arn) | Amazon Resource Name (ARN) for a Code Signing Configuration | `string` | `null` | no |
762764
| <a name="input_compatible_architectures"></a> [compatible\_architectures](#input\_compatible\_architectures) | A list of Architectures Lambda layer is compatible with. Currently x86\_64 and arm64 can be specified. | `list(string)` | `null` | no |

examples/complete/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ module "lambda_function" {
5151
Serverless = "Terraform"
5252
}
5353

54+
cloudwatch_logs_log_group_class = "INFREQUENT_ACCESS"
55+
5456
role_path = "/tf-managed/"
5557
policy_path = "/tf-managed/"
5658

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ resource "aws_cloudwatch_log_group" "lambda" {
221221
name = coalesce(var.logging_log_group, "/aws/lambda/${var.lambda_at_edge ? "us-east-1." : ""}${var.function_name}")
222222
retention_in_days = var.cloudwatch_logs_retention_in_days
223223
kms_key_id = var.cloudwatch_logs_kms_key_id
224+
skip_destroy = var.cloudwatch_logs_skip_destroy
225+
log_group_class = var.cloudwatch_logs_log_group_class
224226

225227
tags = merge(var.tags, var.cloudwatch_logs_tags)
226228
}

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,18 @@ variable "cloudwatch_logs_kms_key_id" {
432432
default = null
433433
}
434434

435+
variable "cloudwatch_logs_skip_destroy" {
436+
description = "Whether to keep the log group (and any logs it may contain) at destroy time."
437+
type = bool
438+
default = false
439+
}
440+
441+
variable "cloudwatch_logs_log_group_class" {
442+
description = "Specified the log class of the log group. Possible values are: `STANDARD` or `INFREQUENT_ACCESS`"
443+
type = string
444+
default = null
445+
}
446+
435447
variable "cloudwatch_logs_tags" {
436448
description = "A map of tags to assign to the resource."
437449
type = map(string)

wrappers/alias/versions.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.9"
8+
}
9+
}
310
}

wrappers/deploy/versions.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 3.35"
8+
}
9+
local = {
10+
source = "hashicorp/local"
11+
version = ">= 1.0"
12+
}
13+
null = {
14+
source = "hashicorp/null"
15+
version = ">= 2.0"
16+
}
17+
}
318
}

wrappers/docker-build/versions.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.22"
8+
}
9+
docker = {
10+
source = "kreuzwerker/docker"
11+
version = ">= 3.0"
12+
}
13+
null = {
14+
source = "hashicorp/null"
15+
version = ">= 2.0"
16+
}
17+
}
318
}

wrappers/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ module "wrapper" {
2121
authorization_type = try(each.value.authorization_type, var.defaults.authorization_type, "NONE")
2222
build_in_docker = try(each.value.build_in_docker, var.defaults.build_in_docker, false)
2323
cloudwatch_logs_kms_key_id = try(each.value.cloudwatch_logs_kms_key_id, var.defaults.cloudwatch_logs_kms_key_id, null)
24+
cloudwatch_logs_log_group_class = try(each.value.cloudwatch_logs_log_group_class, var.defaults.cloudwatch_logs_log_group_class, null)
2425
cloudwatch_logs_retention_in_days = try(each.value.cloudwatch_logs_retention_in_days, var.defaults.cloudwatch_logs_retention_in_days, null)
26+
cloudwatch_logs_skip_destroy = try(each.value.cloudwatch_logs_skip_destroy, var.defaults.cloudwatch_logs_skip_destroy, false)
2527
cloudwatch_logs_tags = try(each.value.cloudwatch_logs_tags, var.defaults.cloudwatch_logs_tags, {})
2628
code_signing_config_arn = try(each.value.code_signing_config_arn, var.defaults.code_signing_config_arn, null)
2729
compatible_architectures = try(each.value.compatible_architectures, var.defaults.compatible_architectures, null)

wrappers/versions.tf

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.32"
8+
}
9+
external = {
10+
source = "hashicorp/external"
11+
version = ">= 1.0"
12+
}
13+
local = {
14+
source = "hashicorp/local"
15+
version = ">= 1.0"
16+
}
17+
null = {
18+
source = "hashicorp/null"
19+
version = ">= 2.0"
20+
}
21+
}
322
}

0 commit comments

Comments
 (0)