Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

main.tf 1.2 KB

You have to be logged in to leave a comment. Sign In
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
  1. resource "aws_kinesis_stream" "weather_stream" {
  2. name = "${var.project}-stream"
  3. shard_count = 1
  4. retention_period = 24
  5. }
  6. resource "aws_iam_role" "lambda_exec_role" {
  7. name = "${var.project}-lambda-role"
  8. assume_role_policy = jsonencode({
  9. Version = "2012-10-17",
  10. Statement = [{
  11. Effect = "Allow",
  12. Principal = {
  13. Service = "lambda.amazonaws.com"
  14. },
  15. Action = "sts:AssumeRole"
  16. }]
  17. })
  18. }
  19. resource "aws_iam_role_policy_attachment" "lambda_policy" {
  20. role = aws_iam_role.lambda_exec_role.name
  21. policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
  22. }
  23. resource "aws_lambda_function" "weather_predictor" {
  24. function_name = "${var.project}-lambda"
  25. s3_bucket = var.s3_bucket
  26. s3_key = var.s3_key
  27. runtime = "python3.10"
  28. handler = "lambda_function.lambda_handler" # ← file.function
  29. role = aws_iam_role.lambda_exec_role.arn
  30. timeout = 30
  31. }
  32. resource "aws_lambda_event_source_mapping" "kinesis_trigger" {
  33. event_source_arn = aws_kinesis_stream.weather_stream.arn
  34. function_name = aws_lambda_function.weather_predictor.arn
  35. starting_position = "LATEST"
  36. batch_size = 1
  37. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...