Skip to content

Commit 89e622e

Browse files
committed
add aws_caller_identity to lambda_layers
1 parent 9111ecd commit 89e622e

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

infrastructure/lambda-layers.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
module "lambda-layer-core" {
22
source = "./modules/lambda_layers"
3-
account_id = data.aws_caller_identity.current.account_id
43
layer_name = "core"
54
}
65

76
module "lambda-layer-data" {
87
source = "./modules/lambda_layers"
9-
account_id = data.aws_caller_identity.current.account_id
108
layer_name = "data"
119
}
1210

1311
module "lambda-layer-alerting" {
1412
source = "./modules/lambda_layers"
15-
account_id = data.aws_caller_identity.current.account_id
1613
layer_name = "alerting"
1714
}
1815

1916
module "lambda-layer-reports" {
2017
source = "./modules/lambda_layers"
21-
account_id = data.aws_caller_identity.current.account_id
2218
layer_name = "reports"
2319
}

infrastructure/modules/lambda_layers/iam.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ resource "aws_iam_policy" "lambda_layer_policy" {
1111
"lambda:ListLayers"
1212
],
1313
Resource = [
14-
"arn:aws:lambda:eu-west-2:${var.account_id}:layer:${local.lambda_layer_aws_name}:*"
14+
"arn:aws:lambda:eu-west-2:${data.aws_caller_identity.current.account_id}:layer:${local.lambda_layer_aws_name}:*"
1515
]
1616
}
1717
]
1818
})
19-
}
19+
}
20+

infrastructure/modules/lambda_layers/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ locals {
22
lambda_layer_aws_name = "${terraform.workspace}_${var.layer_name}_lambda_layer"
33
}
44

5+
data "aws_caller_identity" "current" {}
6+
57
data "archive_file" "lambda_layer_placeholder" {
68
type = "zip"
79
source_file = "placeholder_lambda.py"

infrastructure/modules/lambda_layers/variable.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
variable "account_id" {
2-
description = "The AWS account ID used to generate IAM policy for layer access."
3-
type = string
4-
}
5-
61
variable "layer_name" {
72
description = "Logical name assigned to the Lambda layer."
83
type = string

0 commit comments

Comments
 (0)