-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
45 lines (35 loc) · 1.29 KB
/
main.tf
File metadata and controls
45 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
locals {
source_dir = var.source_dir
use_prebuilt_zip = var.filename != null
}
# Create zip package from source directory (only when not using prebuilt)
data "archive_file" "layer_zip" {
count = !local.use_prebuilt_zip ? 1 : 0
type = "zip"
source_dir = local.source_dir
output_path = "${path.module}/.terraform/tmp/${module.this.id}.zip"
}
# Lambda layer
resource "aws_lambda_layer_version" "this" {
layer_name = module.this.id
filename = local.use_prebuilt_zip ? var.filename : data.archive_file.layer_zip[0].output_path
source_code_hash = local.use_prebuilt_zip ? null : data.archive_file.layer_zip[0].output_base64sha256
compatible_runtimes = var.compatible_runtimes
compatible_architectures = var.compatible_architectures
description = var.description
license_info = var.license_info
depends_on = [data.archive_file.layer_zip]
}
# SSM parameters for layer integration
resource "aws_ssm_parameter" "layer_arn" {
name = "/${module.this.id}/layer_arn"
type = "String"
value = aws_lambda_layer_version.this.arn
tags = module.this.tags
}
resource "aws_ssm_parameter" "layer_version" {
name = "/${module.this.id}/layer_version"
type = "String"
value = aws_lambda_layer_version.this.version
tags = module.this.tags
}