Skip to content

Commit

Permalink
Add overrule for the SG feature
Browse files Browse the repository at this point in the history
Add explicit toggle to prevent the "Cannot calculate" error in TF when a new Lambda is deployed.
  • Loading branch information
fatbasstard committed Feb 8, 2024
1 parent a942645 commit 43fe6f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Local .terraform directories
**/.terraform/*
*.lock.hcl

# .tfstate files
*.tfstate
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
locals {
create_event_invoke_config = var.retries != null || var.destination_on_failure != null || var.destination_on_success != null ? { create : true } : {}
create_policy = var.create_policy != null ? var.create_policy : var.role_arn == null
create_security_group = var.create_security_group != null ? var.create_security_group : var.subnet_ids != null && var.security_group_id == null
dead_letter_config = var.dead_letter_target_arn != null ? { create : true } : {}
environment = var.environment != null ? { create : true } : {}
ephemeral_storage = var.ephemeral_storage_size != null ? { create : true } : {}
Expand Down Expand Up @@ -72,7 +73,7 @@ data "aws_subnet" "selected" {

resource "aws_security_group" "default" {
#checkov:skip=CKV2_AWS_5: False positive finding, the security group is attached.
count = var.subnet_ids != null && var.security_group_id == null ? 1 : 0
count = local.create_security_group ? 1 : 0

name = var.security_group_name_prefix == null ? var.name : null
name_prefix = var.security_group_name_prefix != null ? var.security_group_name_prefix : null
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ variable "create_policy" {
description = "Overrule whether the Lambda role policy has to be created"
}

variable "create_security_group" {
type = bool
default = null
description = "Overrule whether the default VPC Security group has to be created"
}

variable "create_s3_dummy_object" {
type = bool
default = true
Expand Down

0 comments on commit 43fe6f3

Please sign in to comment.