-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
58 lines (44 loc) · 1.19 KB
/
s3.tf
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
46
47
48
49
50
51
52
53
54
55
56
57
58
## Buckets
resource "aws_s3_bucket" "lambda" {
bucket_prefix = "lambda-"
}
resource "aws_s3_bucket" "alb_logs" {
bucket_prefix = "alb-logs-"
}
## Policies
resource "aws_s3_bucket_policy" "alb_logs" {
bucket = aws_s3_bucket.alb_logs.id
policy = data.aws_iam_policy_document.alb_logs.json
}
## Objects
data "archive_file" "dummy_zip" {
type = "zip"
output_path = "dummy.zip"
source {
content = "content"
filename = "filename"
}
}
resource "terraform_data" "dummy_revision" {
input = data.archive_file.dummy_zip.output_md5
}
resource "aws_s3_object" "demo_layers" {
for_each = var.demo_config.layers
bucket = aws_s3_bucket.lambda.id
key = "layers/demo/${each.key}.zip"
source = data.archive_file.dummy_zip.output_path
checksum_algorithm = "SHA256"
lifecycle {
replace_triggered_by = [terraform_data.dummy_revision]
}
}
resource "aws_s3_object" "demo_functions" {
for_each = var.demo_config.functions
bucket = aws_s3_bucket.lambda.id
key = "functions/demo/${each.key}.zip"
source = data.archive_file.dummy_zip.output_path
checksum_algorithm = "SHA256"
lifecycle {
replace_triggered_by = [terraform_data.dummy_revision]
}
}