-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
47 lines (41 loc) · 1.09 KB
/
main.tf
File metadata and controls
47 lines (41 loc) · 1.09 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
46
47
terraform {
required_providers {
time = {
source = "hashicorp/time"
version = "0.12.1"
}
}
}
resource "aws_s3_bucket" "original_images" {
bucket = "original-images"
force_destroy = true
tags = {
Name = "Original Images Bucket"
}
}
resource "aws_s3_bucket" "resized_images" {
bucket = "resized-images"
force_destroy = true
tags = {
Name = "Resized Images Bucket"
}
}
resource "aws_lambda_function" "image_resizer" {
filename = "lambda.zip"
function_name = "ImageResizerFunction"
handler = "lambda_function.lambda_handler"
runtime = "python3.11"
timeout = 60
role = "arn:aws:iam::000000000000:role/lambda-role"
}
resource "aws_s3_bucket_notification" "original_images_notification" {
bucket = aws_s3_bucket.original_images.id
lambda_function {
lambda_function_arn = aws_lambda_function.image_resizer.arn
events = ["s3:ObjectCreated:*"]
}
}
output "lambda_function_arn" {
description = "The ARN of the Lambda function"
value = aws_lambda_function.image_resizer.arn
}