Skip to content

Commit

Permalink
Add new output
Browse files Browse the repository at this point in the history
  • Loading branch information
fatbasstard committed Mar 7, 2024
1 parent 0f58d3a commit 0784ae5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ locals {
source_code_hash = var.source_code_hash != null ? var.source_code_hash : var.filename != null ? filebase64sha256(var.filename) : null
tracing_config = var.tracing_config_mode != null ? { create : true } : {}
vpc_config = var.subnet_ids != null ? { create : true } : {}
security_group_ids = length(var.security_group_ids) > 0 ? [var.security_group_ids] : [aws_security_group.default[0].id]
security_group_ids = length(var.security_group_ids) > 0 ? var.security_group_ids : [aws_security_group.default[0].id]
}

data "aws_iam_policy_document" "default" {
Expand Down Expand Up @@ -87,7 +87,7 @@ resource "aws_security_group" "default" {
}

resource "aws_vpc_security_group_egress_rule" "default" {
for_each = var.subnet_ids != null && length(var.security_group_egress_rules) != 0 ? { for v in var.security_group_egress_rules : v.description => v } : {}
for_each = var.subnet_ids != null && length(var.security_group_ids) == 0 && length(var.security_group_egress_rules) != 0 ? { for v in var.security_group_egress_rules : v.description => v } : {}

cidr_ipv4 = each.value.cidr_ipv4
cidr_ipv6 = each.value.cidr_ipv6
Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ output "security_group_id" {
description = "If the Lambda is deployed into a VPC this will output the genetered security group id (if no security groups are specified)"
}

output "security_group_ids" {
value = local.security_group_ids
description = "List of all the security group ids associated with the Lambda"
}

output "version" {
value = aws_lambda_function.default.version
description = "Latest published version of the Lambda function"
Expand Down

0 comments on commit 0784ae5

Please sign in to comment.