Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
resource "aws_lambda_function" "this" {
region = var.region

function_name = var.function_name
description = var.description

Expand Down Expand Up @@ -80,6 +82,8 @@ resource "aws_iam_role_policy" "cloudwatch-log-group" {
}

resource "aws_cloudwatch_log_group" "this" {
region = var.region

name = "/aws/lambda/${var.function_name}"

retention_in_days = var.cloudwatch_log_group_retention_in_days
Expand Down Expand Up @@ -110,6 +114,8 @@ locals {
resource "aws_security_group" "this" {
for_each = local.vpc_configs

region = var.region

name = "lambda-${var.function_name}"
description = "Lambda: ${var.function_name}"
vpc_id = each.value.vpc.id
Expand All @@ -126,6 +132,8 @@ resource "aws_security_group" "this" {
resource "aws_security_group_rule" "egress" {
for_each = aws_security_group.this

region = var.region

security_group_id = each.value.id

type = "egress"
Expand Down Expand Up @@ -192,6 +200,8 @@ data "aws_partition" "current" {

data "aws_region" "current" {
for_each = local.vpc_configs

region = var.region
}

data "aws_caller_identity" "current" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ VPC configuration of the Lambda function:
If `vpc_config` is `null` the Lambda function will not be placed into a VPC.
EOS
}

variable "region" {
description = "Region where the resource(s) will be managed. Defaults to the region set in the provider configuration"
type = string
default = null
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
}
aws = {
source = "hashicorp/aws"
version = ">= 3"
version = ">= 6.0"
}
}
}