-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstories_sfn.tf
80 lines (65 loc) · 1.96 KB
/
stories_sfn.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module batch_stories_sfn {
source = "terraform-aws-modules/step-functions/aws"
name = "${local.project_name}-batch-stories-sfn"
definition = templatefile("${path.module}/sfn_def/batch_stories_def.json", {
BATCH_STORIES_FETCH_PARSE_LAMBDA_ARN = module.batch_stories_fetch_parse_lambda.lambda_function_arn
})
# allow step function to invoke other service
#
# Warning:
# Needs to create `module.scraper_lambda` before creating this step_function
service_integrations = {
lambda = {
lambda = [
module.batch_stories_fetch_parse_lambda.lambda_function_arn
]
}
}
type = "STANDARD"
tags = {
Project = local.project_name
}
}
module batch_stories_fetch_parse_lambda {
source = "terraform-aws-modules/lambda/aws"
create_function = true
function_name = "${local.project_name}-batch-stories-fetch-parse"
description = "Batch fetch and parse all stories of a landing page"
handler = "stories"
runtime = "go1.x"
source_path = [{
path = "${path.module}/../lambda_golang/"
commands = ["go build ./cmd/stories", ":zip"]
patterns = ["stories"]
}]
timeout = 900
cloudwatch_logs_retention_in_days = 7
publish = true
attach_policy_statements = true
policy_statements = {
pipeline_sqs = {
effect = "Allow",
actions = ["sqs:SendMessage", "sqs:GetQueueUrl"],
resources = [module.stories_queue.this_sqs_queue_arn]
}
s3_archive_bucket = {
effect = "Allow",
actions = [
"s3:PutObject",
"s3:GetObject"
],
resources = ["${data.aws_s3_bucket.archive.arn}/*"]
}
}
environment_variables = {
STORIES_QUEUE_NAME = module.stories_queue.this_sqs_queue_name
SLACK_WEBHOOK_URL = var.slack_post_webhook_url
LOG_LEVEL = "DEBUG"
DEBUG = "true"
S3_ARCHIVE_BUCKET = data.aws_s3_bucket.archive.id
NEWSSITE_ECONOMY = data.aws_ssm_parameter.newssite_economy.value
}
tags = {
Project = local.project_name
}
}